getvalue(2)获得空 [英] getvalue(2) get null
本文介绍了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
推荐答案
try
try
gcbranch = BranchReader[2].ToString();
gcaddress = BranchReader[3].ToString();
gcuser = BranchReader[0].ToString();
gcpassword = BranchReader[1].ToString();
在旋转时会返回一个布尔值,它会被您的应用程序调用一次,因此在结束时它可能会返回null.尝试使用a旋转和int temp值.临时使用temp ++进行旋转.记住,每次旋转时都要使用BranchReader.Read()方法;
这是这些查询错误之一.请尝试并返回给我.
When you use BranchReader.Read() in a While rotation it will return a bool value and it will called by your application one time so when it comes to end it can return null.Try to use a for rotation and int temp value.Remember to increase your temp''s value on every rotation with temp++.And remember to use your BranchReader.Read() method on every for rotation''s begining;
This is one of these query mistakes.Try and return to me.
这篇关于getvalue(2)获得空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文