获取sqlcommand的值

获取sqlcommand的值

本文介绍了获取sqlcommand的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

这是我的代码:

 SqlDataReader dReader; 
SqlConnection conn = new SqlConnection( @ 数据源= .\sql2008;初始目录= jelvehsadb;集成安全性=真;);
SqlCommand comm = new SqlCommand();
comm.Connection = conn;

comm.CommandText = @ 从work_with_us中选择响应,其中national_code = @ CustomerID;
comm.Parameters.AddWithValue( CustomerID 00488 );
comm.Connection.Open();


dReader = comm.ExecuteReader();

if (dReader.HasRows == true
{
TxtShow.Text = ???;
}


}



我的问题是如何从dreader获得我的回复?

结果必须在txtshow上显示。

谢谢

解决方案




hi dear's,
this is my code:

SqlDataReader dReader;
        SqlConnection conn = new SqlConnection(@"Data Source=.\sql2008;Initial Catalog=jelvehsadb;Integrated Security=True;");
        SqlCommand comm = new SqlCommand();
        comm.Connection = conn;

        comm.CommandText = @"Select response from work_with_us where national_code =@CustomerID";
        comm.Parameters.AddWithValue("CustomerID", 00488);  
        comm.Connection.Open();
        

        dReader = comm.ExecuteReader();
          
        if (dReader.HasRows == true)
        {
            TxtShow.Text = ???;
        }
        

    }


my problem is how i can get my response vlaue from dreader??
the result must show on txtshow.
thanks

解决方案




这篇关于获取sqlcommand的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 06:59