第3个回答 2011-06-30
protected void Page_Load(object sender, EventArgs e)
{
getStudent_sourceIdByName()
}
private static SqlConnection connection;
public static SqlConnection Connection
{
get
{
string connectionString = "server=localhost;database=数据库名;uid=sa;password=123456";
if (connection == null)
{
connection = new SqlConnection(connectionString);
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Broken)
{
connection.Close();
connection.Open();
}
return connection;
}
private void getStudent()
{
String sql = " SELECT * from dbo.UserInfo ";
SqlCommand cmd = new SqlCommand(sql, Connection);
DataTable dt = (int)cmd.ExecuteReader();
txtName.Text=dt.Rows[0]["name"].ToString();
txtSex.Text=dt.Rows[0]["sex"].ToString();
}
我是从“上海全鼎软件学院”毕业的————————