如何通过asp.net中的文本框更新数据库内容 [英] how to update database contents through text boxes in asp.net
本文介绍了如何通过asp.net中的文本框更新数据库内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过asp.net中的文本框更新数据库内容
how to update database contents through text boxes in asp.net
推荐答案
在声明对象时需要使用new关键字.
you need to use new keyword while declaring object.
SqlConnection myconn;
//SqlConnection mycomm;
myconn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=" + Server.MapPath("~\\App_Data\\bhaddal.mdf") + " ;Integrated Security=True;User Instance=True");
myconn.Open();
//string q;
SqlConnection myConn = new SqlConnection(myconn.ConnectionString);
s= WebConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString;
myconn = new SqlConnection(s);
myconn.Open();
cmd = new SqlCommand("update Employee set first='" + TextBox1.Text+ "', secound='" + TextBox2 + "', third='" + TextBox3.Text + "', fourth='" + TextBox5.Text + "', fifth='" + "' rollno='" + TextBox1.Text + "'", myconn);
cmd.ExecuteNonQuery();
//Label1.Text = " Record Updated successfully";
clearData();
将对象作为新MyClass()
例如:
Dim object As New MyClass()
example:
Dim cmd As SqlCommand
cmd = New SqlCommand(sSql, Conn, transaction)
这篇关于如何通过asp.net中的文本框更新数据库内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文