那就从数据库读取这条记录,对应取出各字段的值,
string connectionString = "Data Source=192.168.1.3;Initial Catalog=data;User ID=sa;password=sa;Integrated Security=False";
string queryString = "select 账户,姓名,密码 from table";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
try
{
while (reader.Read())
{
textBox1.Text = reader[0].ToString().Trim();
textBox2.Text = reader[1].ToString().Trim();
textBox3.Text = reader[2].ToString().Trim();
……
}
}
finally
{
command.Dispose();
connection.Close();
}
}
string connectionString = "Data Source=192.168.1.3;Initial Catalog=data;User ID=sa;password=sa;Integrated Security=False";
string queryString = "select 账户,姓名,密码 from table";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
try
{
while (reader.Read())
{
textBox1.Text = reader[0].ToString().Trim();
textBox2.Text = reader[1].ToString().Trim();
textBox3.Text = reader[2].ToString().Trim();
……
}
}
finally
{
command.Dispose();
connection.Close();
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货