查看: 818|回复: 3
|
可以帮我看看这有问题吗~~~
[复制链接]
|
|
这是我写的会员注册的表格。。。 但好像有问题。。。
资料不能记录~~~
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();
} |
|
|
|
|
|
|
|
发表于 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以确定日与月没被系统搞错 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|