C#.net ,报错说标准表达式中数据类型不匹配 涉及到Access中货币类型Money字段
第一次发这个问题不知为何没提交成功!!!!气人!!主要针对AccountLog表中的Money字段,对某一个UserID,direction为IN的Money字段值的和减...
第一次发这个问题不知为何没提交成功!!!!气人!!
主要针对AccountLog表中的Money字段,对某一个UserID,direction为IN的Money字段值的和减去direction为OUT的Money字段值,把相减得到的值用一个名为Balance的label控件显示!
代码下面:
private void BalanceInquire_Load(object sender, EventArgs e)
{
OleDbConnection oc = new OleDbConnection(ConfigurationManager.ConnectionStrings["ButterflyConnectionString"].ConnectionString);
oc.Open();
String strin = "select SUM([Money]) As income from AccountLog where UserID='" + BIUserID + "' and Direction ='IN'";
String strout = "select SUM([Money]) As payment from AccountLog Where UserID='" + BIUserID + "' and Direction = 'OUT'";
OleDbCommand comin = new OleDbCommand(strin);
comin.Connection = oc;
OleDbDataReader drin = comin.ExecuteReader();
OleDbCommand comout = new OleDbCommand(strout);
comin.Connection = oc;
OleDbDataReader drout = comout.ExecuteReader();
try
{
if (drin.Read() &&
drout.Read())
{ balance.Text = ((decimal)drin["income"] - (decimal)drout["payment"]).ToString(); }
else { MessageBox.Show("错!");} }
catch(Exception ex)
{
balance.Text = ex.Message;
}
finally
{
drin.Close();
drout.Close();
oc.Close();
}
}
}
现在第二句comin.Connection = oc;已改成comout.Connection = oc; 另外前面有代码:private static int BIUserID;
public BalanceInquire(int l1)
{
InitializeComponent();
BIUserID = l1;
}
而,再到退前面一个窗体
private void 余额查询ToolStripMenuItem_Click(object sender, EventArgs e)
{
ManageAccount.BalanceInquire frm = new ManageAccount.BalanceInquire(Login.USERID);
frm.MdiParent = this;
frm.Show();
}
再到退到主启动窗体:
public static int USERID; 这是USERID字段的定义
拜托!!!高手帮帮我啊!!!! 展开
主要针对AccountLog表中的Money字段,对某一个UserID,direction为IN的Money字段值的和减去direction为OUT的Money字段值,把相减得到的值用一个名为Balance的label控件显示!
代码下面:
private void BalanceInquire_Load(object sender, EventArgs e)
{
OleDbConnection oc = new OleDbConnection(ConfigurationManager.ConnectionStrings["ButterflyConnectionString"].ConnectionString);
oc.Open();
String strin = "select SUM([Money]) As income from AccountLog where UserID='" + BIUserID + "' and Direction ='IN'";
String strout = "select SUM([Money]) As payment from AccountLog Where UserID='" + BIUserID + "' and Direction = 'OUT'";
OleDbCommand comin = new OleDbCommand(strin);
comin.Connection = oc;
OleDbDataReader drin = comin.ExecuteReader();
OleDbCommand comout = new OleDbCommand(strout);
comin.Connection = oc;
OleDbDataReader drout = comout.ExecuteReader();
try
{
if (drin.Read() &&
drout.Read())
{ balance.Text = ((decimal)drin["income"] - (decimal)drout["payment"]).ToString(); }
else { MessageBox.Show("错!");} }
catch(Exception ex)
{
balance.Text = ex.Message;
}
finally
{
drin.Close();
drout.Close();
oc.Close();
}
}
}
现在第二句comin.Connection = oc;已改成comout.Connection = oc; 另外前面有代码:private static int BIUserID;
public BalanceInquire(int l1)
{
InitializeComponent();
BIUserID = l1;
}
而,再到退前面一个窗体
private void 余额查询ToolStripMenuItem_Click(object sender, EventArgs e)
{
ManageAccount.BalanceInquire frm = new ManageAccount.BalanceInquire(Login.USERID);
frm.MdiParent = this;
frm.Show();
}
再到退到主启动窗体:
public static int USERID; 这是USERID字段的定义
拜托!!!高手帮帮我啊!!!! 展开
若以下回答无法解决问题,邀请你更新回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询