且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

尝试更新App_code文件夹中SQL本地数据库中的记录时出现错误

更新时间:2022-06-21 01:34:35

该错误消息非常清楚.您要附加的数据库已经在SQLEXPRESS中附加了,因此您不能再做一次.如果该数据库已经连接,则只需连接到该实例,而不是尝试重新附加它.
The error message is quite clear. The database you are attempting to attach to is already attached in SQLEXPRESS so you can''t do it again. If the db is already attached, just connect to the instance instead of trying to reattach it.


这可能是问题

cmd.CommandText =插入到class10(subject,chapter_name,chapter_number,exercise_number,url)VALUES(``DropDownList1.SelectedValue'',``ChapterBox.Text'',``TextBox1.Text'',``TextBox2.文字)";


没有空格,应该为"Insert INTO ......."
This could be the issue

cmd.CommandText="Insert IN TO class10(subject,chapter_name,chapter_number,exercise_number,url) VALUES (''DropDownList1.SelectedValue'',''ChapterBox.Text'',''TextBox1.Text'',''TextBox2.Text'' )";


No space, Should be "Insert INTO......."


尝试一下
Try this
cmd.CommandText="Insert into class10(subject,chapter_name,chapter_number,exercise_number,url) VALUES ('"+ DropDownList1.SelectedValue+"','"+ChapterBox.Text.Trim()+"','"+TextBox1.Text.Trim()+"','"+TextBox2.Text.Trim()+"' )";



注意:使用参数化查询,请遵循URL
http://forums.asp.net/t/1374619.aspx/1 [ ^ ]

谢谢



Note : Use Parameterzed Query, Follow the URL
http://forums.asp.net/t/1374619.aspx/1[^]

Thanks