佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 818|回复: 3

可以帮我看看这有问题吗~~~

[复制链接]
发表于 5-12-2006 12:47 AM | 显示全部楼层 |阅读模式
这是我写的会员注册的表格。。。 但好像有问题。。。
资料不能记录~~~

private void btnSubmit_Click(object sender, System.EventArgs e)
   {
        OleDbConnection conMember;
        OleDbCommand cmdInsert;
        string strInsert;

conMember = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\SHome\\Member.mdb");


strInsert = "INSERT INTO Member (UserName, FirstName, LastName, Password, ConfirmPassword, Email, ConfirmEmail,Gender, Address, Country, PostalCode, DateOfBirth) Values (@UserName, @FirstName, @LastName,@Password, @ConfirmPassword, @Email, @ConfirmEmail,@Gender, @Address, @Country, @PostalCode, @DateOfBirth)";

cmdInsert = new OleDbCommand( strInsert, conMember);

cmdInsert.Parameters.Add("@UserName", txtname.Text);
cmdInsert.Parameters.Add("@FirstName", txtfname.Text);
cmdInsert.Parameters.Add("@LastName", txtlname.Text);
cmdInsert.Parameters.Add("@Password", txtpassword.Text);
cmdInsert.Parameters.Add("@ConfirmPassword", txtcpassword.Text);
cmdInsert.Parameters.Add("@Email", txtemail.Text);
cmdInsert.Parameters.Add("@ConfirmEmail", txtcemail.Text);
cmdInsert.Parameters.Add("@Gender", rdlgender.SelectedItem.Text);
cmdInsert.Parameters.Add("@Address", txtaddr.Text);
cmdInsert.Parameters.Add("@Country", drpcountry.SelectedItem.Text);
cmdInsert.Parameters.Add("@PostalCode", txtpostal.Text);
cmdInsert.Parameters.Add("@DateOfBirth", txtdob.Text);

conMember.Open();

if (conMember.State == ConnectionState.Open)
Response.Write("Succesfully open the database connection");
                               
cmdInsert.ExecuteNonQuery();

conMember.Close();

   }
回复

使用道具 举报


ADVERTISEMENT

发表于 5-12-2006 01:13 AM | 显示全部楼层
至少你把error message放出来,
比较一目了然吧?
回复

使用道具 举报

 楼主| 发表于 5-12-2006 01:18 AM | 显示全部楼层
原帖由 WuSheng 于 5-12-2006 01:13 AM 发表
至少你把error message放出来,
比较一目了然吧?


Server Error in '/SHome' Application.
--------------------------------------------------------------------------------

Syntax error in INSERT INTO statement.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.

Source Error:


Line 104:Response.Write("Succesfully open the database connection");
Line 105:                               
Line 106:cmdInsert.ExecuteNonQuery();
Line 107:
Line 108:conMember.Close();


Source File: c:\shome\member\register.aspx.cs    Line: 106

Stack Trace:


[OleDbException (0x80040e14): Syntax error in INSERT INTO statement.]
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
   System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
   System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
   System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
   SHome.Member.Register.btnSubmit_Click(Object sender, EventArgs e) in c:\shome\member\register.aspx.cs:106
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain()
回复

使用道具 举报

发表于 5-12-2006 11:41 AM | 显示全部楼层
只是SQL statement有问题,查看看是不是你pass进去的value不match with datatype,如DateOfBirth是不是pass进日期格式

我建议日期格式用yyyy-MM-dd以确定日与月没被系统搞错
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 14-11-2024 04:17 AM , Processed in 0.107801 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表