strSQL = "update table set title=@title,content=@content where id="+id+""
myConn = New OleDbConnection(strConn)
myCommand = New OleDbCommand(strSQL, myConn)
myCommand.Parameters.Add("@title",new_title.text)
myCommand.Parameters.Add("@content",content.text)
 
strSQL = "insert into table (title,content) values (@title, @content)"
myCommand = New OleDbCommand(strSQL, myConn)
myCommand.Parameters.Add("@title",new_title.text)
myCommand.Parameters.Add("@content",content.text)

这样写可以,,,,

有一个奇怪的问题,,,,当
myCommand.Parameters.Add("@title",new_title.text)
myCommand.Parameters.Add("@content",content.text)
的顺序是
myCommand.Parameters.Add("@content",content.text)
myCommand.Parameters.Add("@title",new_title.text)
时,,,那么添加后的记录tilte 和 content 就换位了,难道@title不是类似ID的作用? 不理解~~~


补充(这个没试)
string strSql = "insert into table1 (col1,col2) values (@col1,@col2)";
SqlParameter [] Params = new SqlParameter[2];
Params[1] = new SqlParameter();
Params[1].ParameterName = "@col1";
Params[1].value = "aaron's blog";
posted on 2005-04-19 10:35  aaron.net  阅读(406)  评论(0编辑  收藏  举报