我只需要知道代码,单击按钮如何从C#和ASP.NET到文本框中的数据库中检索数据。
如果您使用的是MS SQL,请尝试使用::
using System.Data.SQLClient;
Class DataExtract
{
Public DataTable Extract()
{
SqlConnection con = new SqlConnection("Data Source = .;
Initial Catalog = domain;
Integrated Security = True");
con.Open();
SqlCommand cmd = new SqlCommand("Select * from tablename", con);
Return new DataTable().load(cmd.ExecuteReader());
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句