[求助]插入数据库问题(以解决,谢谢!)
我写的一个小的流言本程序,但是当点击提交按钮时总是出现这个问题
源程序代码如下
if(this.Page.IsValid)
{
OleDbConnection con=DB.createConnection();
con.Open();
string gName,gEmail,gHomePage,gTopic,gSpeak,gSpeakDate;
gName=(this.txtName.Text).ToString();
// Response.Write(gName);
// Response.End();
gEmail=(this.txtEmail.Text).ToString();
gHomePage=(this.txtHomePage.Text).ToString();
gTopic=(this.txtTopic.Text).ToString();
gSpeak=(this.txtSpeak.Text).ToString();
gSpeakDate="#"+(System.DateTime.Now).ToString()+"#";//获得系统当前时间,转换成字符串。
string str="insert into guestBook(guestName,guestEmail,guestHomePage,guestTopic,guestSpeak,guestSpeakDate) values(@gName,@gEmail,@gHomePage,@gTopic,@gSpeak,@gSpeakDate)";
OleDbCommand cmd=new OleDbCommand(str,con);
cmd.Parameters.Add("@gName",OleDbType.VarChar,50);
cmd.Parameters.Add("@gEmail",OleDbType.VarChar,50);
cmd.Parameters.Add("@gHomePage",OleDbType.VarChar,50);
cmd.Parameters.Add("@gTopic",OleDbType.VarChar,50);
cmd.Parameters.Add("@gSpeak",OleDbType.VarChar,1500);
cmd.Parameters.Add("@gSpeakDate",OleDbType.Date,50);
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect("guestBookList.aspx");
}
请各位高手指点一下,在此非常感谢了。
[此贴子已经被作者于2006-11-28 9:36:54编辑过]