qq_41115924
kuying81
2017-11-20 04:52

System.Data.DataRowView,求助各位大神。

  • c#

本人弄个商城数据可文件,但是出现这中问题System.Data.DataRowView,求助各位大神。
namespace Webshop
{
public partial class 登录 : Form
{
public 登录()
{
InitializeComponent();
}

    SqlConnection conn;
    SqlCommand com;
    SqlDataAdapter da;
    SqlDataReader dr;

    public static string un;
    public static string ur;

    private void 登录_Load(object sender, EventArgs e)
    {
        conn = new SqlConnection("server=.;database=Webshop;integrated security = true");
        conn.Open();
        da = new SqlDataAdapter("select u_Name from Users", conn);
        DataSet ds = new DataSet();
        da.Fill(ds,"Users");
        conn.Close();
        comboBox1.DataSource = ds.Tables["Users"];
        comboBox1.DisplayMember = " u_Name";

    }

    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        conn.Open();
        com = new SqlCommand("select  u_Type from Users where  u_Name ='" + comboBox1.Text+ "'", conn);
        dr = com.ExecuteReader();
        if (dr.Read())
        {
            textBox1.Text = dr["u_Type"].ToString();
        }
        conn.Close();
        dr.Close();




    }

}

}图片说明

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐