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

问题描述

大家好

我有这种语法

hi all

i have this syntax

lcuser = this.txtUserName.Value;
       lcpassword = this.txtPassword.Value;
       SqlConnection con = new SqlConnection("Data source = UIS-PC\\SQLEXPRESS; Initial Catalog=Database1; integrated security = SSPI;");
       SqlCommand selectid = new SqlCommand("SELECT cuser, cpassword, cbranch, caddress FROM branch", con);
       con.Open();
       SqlDataReader BranchReader = selectid.ExecuteReader();
       int branch = BranchReader.GetOrdinal("caddress");
       while (BranchReader.Read())
       {

           gcbranch = BranchReader.GetName(2).ToString();
           gcaddress = BranchReader[2].ToString();
           gcuser = BranchReader.GetValue(3).ToString();
           gcpassword = BranchReader.GetValue(2).ToString();



尽管我已将其填入表数据库中,但GetValue(2)显示为空
GetValue(2)有时显示为空,尽管它们具有数据

在此先感谢



GetValue(2) shows null although i have it filled in the table database
GetValue(2) some times shows empty although they have data

thanks in advance

推荐答案

gcbranch = BranchReader[2].ToString();
gcaddress = BranchReader[3].ToString();
gcuser = BranchReader[0].ToString();
gcpassword = BranchReader[1].ToString();



这篇关于getvalue(2)获得空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 10:38