任何查询返回空数据集 [英] any query return empty dataset
本文介绍了任何查询返回空数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请在下面找到我的代码,请注意,除了最后一个revivetotal()都是空数据集之外,我所有的函数都运行正常,即使我将任何可在其他函数和形式中使用的查询放入
Pls find my code below and note that all my functions run coorectly except the last revivetotal() were iam getting null dataset even if i put any query that work in another functions and forms
public DriverPaymentForm(DriverPaymentBean driverpaymentbean)
{
InitializeComponent();
fillForm(driverpaymentbean);
showallPaymentbyjobcode();
revievetotal();
addtotalpaid();
}
public void fillForm(DriverPaymentBean driverpaymentbean)
{
txtjobCode.Text = driverpaymentbean.Jobcode;
txtjobCode.Enabled = false;
txtAcceptorName.Text = driverpaymentbean.Acceptorname;
txtvehicleno.Text = driverpaymentbean.Vehicleno;
}
public void showallPaymentbyjobcode()
{
try
{
String query = "Select jobcode ,vehicleno,amount,postdate,description,ischeque,iscash from driverpaymentmastertable where jobcode Like '" + txtjobCode.Text + "' Order by postdate";
OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);
DataSet ds = new DataSet();
dAdapter.Fill(ds, "tblpayview");
tblpaymentview.DataSource = ds.Tables["tblpayview"].DefaultView;
if (ds.Tables.Count <= 0)
{
lblstatus.Text = "No Payment Details Present";
}
}
catch (Exception)
{
MessageBox.Show("The application had met with some errors please restart the application :\n error:closer MSAccess files");
}
public void addtotalpaid()
{
double sum = 0;
int count = tblpaymentview.RowCount;
if (count != 0)
{
for (int i = 0; i < count; i++)
{
if (tblpaymentview.Rows[i].Cells[3].Value != null)
{
sum = sum + double.Parse(tblpaymentview.Rows[i].Cells[2].Value.ToString());
}
}
lblstatus.Text = sum.ToString();
}
}
public void revievetotal()
{
String query = "Select * from customermastertable ";
OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);
DataSet ds = new DataSet();
}
任何人都可以嘲笑为什么我在reviewtotal()中为任何查询获取空集
[edit]添加了代码块,将我的内容作为纯文本..."选项已禁用-OriginalGriff [/edit]
can anyone sujgest why iam getting empty set for any query in reviewtotal()
[edit]Code block added, "Treat my content as plain text..." option disabled - OriginalGriff[/edit]
推荐答案
因为您没有填写它...
尝试添加以下行:
Because you aren''t filling it...
Try adding the line:
dAdapter.Fill(ds);
这篇关于任何查询返回空数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文