本文介绍了数据表/内部联接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected decimal chk_trainee(string m_memcode, string m_date, int session, SqlConnection conn)
{
SqlCommand cmd = new SqlCommand("SELECT * FROM [t_memsch] WHERE [m_schdate]='" + m_date + "' AND [m_schsession]='" + session + "' AND [m_memcode]='" + m_memcode + "'", conn);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable ds = new DataTable();
sda.Fill(ds);
string m_jobtype = ds.Rows[0]["m_jobtype"].ToString();
string m_memlevel = ds.Rows[0]["m_memlevel"].ToString();
sda.Dispose();
SqlCommand cmd1 = new SqlCommand("SELECT * FROM [m_jobtype] WHERE [m_cjobtypedesc]='" + m_jobtype + "'", conn);
SqlDataAdapter sda1 = new SqlDataAdapter(cmd1);
DataTable ds1 = new DataTable();
sda.Fill(ds1);
string m_jobtypecode = ds1.Rows[0]["m_jobtypecode"].ToString();
sda.Dispose();
SqlCommand cmd2 = new SqlCommand("SELECT * FROM [m_allowance] WHERE [m_jobtypecode]='" + m_jobtypecode + "' AND [m_memlevel]='" + m_memlevel + "' AND '" + m_date + "' BETWEEN [m_effdate] AND [m_expiredate]", conn);
SqlDataAdapter sda2 = new SqlDataAdapter(cmd2);
DataTable ds2 = new DataTable();
sda.Fill(ds2);
return Convert.ToDecimal(ds2.Rows[0]["m_amt"].ToString());;
}
这些编码有问题,我想是由于我不能在一个函数中拥有3个数据表.我知道使用内部联接很容易解决,但是我不知道如何使用内部联接.请任何人帮忙吗?
These coding have problems, i guess is due to i cant have 3 datatables in one function. I know it is easy to solve by using inner join, but however, i dunno how to use innerjoin. Please anyone help? thanks.
推荐答案
这篇关于数据表/内部联接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!