首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

在winform里如何把查到的abc分别赋值给ABC

2013-11-06 
在winform里怎么把查到的abc分别赋值给ABCwinform sql 查询赋值SqlCommand cmd new SqlCommand(select

在winform里怎么把查到的abc分别赋值给ABC
winform sql 查询赋值
SqlCommand cmd = new SqlCommand("select a,b,c from zhengshib where ZCM='" + strREG + "'and ID='" + rjid + "'", data.conn);

在winform里怎么把查到的abc分别赋值给ABC
[解决办法]

SqlConnection conn = new SqlConnection("server=.;database=test;uid=sa;pwd=123456;");
            conn.Open();
            SqlCommand cmd = new SqlCommand("select [id],[name],[password] from users where name='guwei'", conn);
            SqlDataReader reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                this.textBox1.Text = reader.GetInt32(0) + "";
                this.textBox2.Text = reader[1].ToString();
                this.textBox3.Text = reader.GetValue(2).ToString();
            }

[解决办法]
SqlCommand cmd = new SqlCommand("select a,b,c from zhengshib where ZCM='" + strREG + "'and ID='" + rjid + "'", data.conn);
DataTable table = DBProvider.DefaultDBOperator.GetDataTable(cmd);
if (table.Rows.Count > 0)
{
DataRow dr=table.Rows[0];
string strA = dr["a"].ToString();
string strB = dr["b"].ToString();
string strC = dr["c"].ToString();
}

热点排行