asp.net
string str = "server=.;uid=sa;pwd=sa;database=caizhiqiang";conn = new SqlConnection(str);
conn.Open();
我已经连接了数据库......现在怎么在button中绑定到textbox里显示出来呢?
--------------------编程问答-------------------- (大小写自己写吧,我就不较真了)
try{
string str = "server=.;uid=sa;pwd=sa;database=caizhiqiang";
conn = new SqlConnection(str);
conn.Open();
SqlCommand cmd=new SqlCommand("selec * from table",conn);
SqlDataReader reader=cmd.executeReader();
if(reader.read())
{
textbox.Text=reader[索引/列名].ToString();
}
}catch(Exception ex)
{
Response.write(ex.message);
}finally
{
reader.close();
cmd.dispose();
conn.close();
}
以后记得给分哦
--------------------编程问答-------------------- ASP.NET2.0入门经典很适合你
补充:.NET技术 , ASP.NET