- 爱易网页
-
C#教程
- C# 怎么把dataset 内容绑定到textbox上
日期:2014-05-19 浏览次数:20845 次
C# 如何把dataset 内容绑定到textbox上.
代码如下:
class myclass
{
public string sql, table;
SqlConnection mysql = new SqlConnection( "user id=sa;password=;initial catalog=test;Data Source=127.0.0.1;Connect Timeout=30 ");
public DataSet sqlbd(string sql,string table)
{
SqlDataAdapter myadp = new SqlDataAdapter(sql, mysql);
DataSet myds = new DataSet();
try
{
myadp.Fill(myds, table);
return myds;
}
finally
{
myadp.Dispose();
mysql.Close();
}
}
}
private void datagrid2_Click(object sender, EventArgs e)
{
bl = dataGrid2[dataGrid2.CurrentCell.RowNumber, 0].ToString();
mystr.sql = "select * from gztcb where tcm= ' " + bl + " ' ";
mystr.table = "gztcb ";
DataSet ds = new DataSet();
ds = mystr.sqlbd(mystr.sql, mystr.table);
?????????//如何在这里实现...假设表 "gztcb "有3个字段.分别赋值给textbox1.text..textbox2.text..textbox3.text..求大虾帮忙