SQL命令未正确结束 [英] SQL command not properly ended
本文介绍了SQL命令未正确结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须通过使用借贷项搜索员工详细信息. 3个表中提供了详细信息.我已使用join query(oracle)进行显示,但显示错误.
以下是C#代码.
I have to search the employee details by using loanid. The details are available in 3 tables. I have used join query(oracle) to display but it shows error.
Following is the c# code.
try
{
//Search Employee Details
Oracle.DataAccess.Client.OracleConnection cn = new Oracle.DataAccess.Client.OracleConnection();
cn.ConnectionString = "user id=system; password=system;";
Oracle.DataAccess.Client.OracleCommand cmd = new Oracle.DataAccess.Client.OracleCommand();
cmd.Connection = cn;
cmd.CommandText = " select deposit.loanid, form1.empedoj, form1.empshare, sharecapital.shareint, sharecapital.loandt, sharecapital.loandeduc, sharecapital.dividend, sharecapital.sharetot from form1, deposit , sharecapital where deposit.loanid(+) = sharecapital.loanid = ''" + txtlnid.Text.Trim() + "''"; // shows sql command not properly ended
Oracle.DataAccess.Client.OracleDataAdapter ada = new Oracle.DataAccess.Client.OracleDataAdapter(cmd);
System.Data.DataTable dt = new DataTable();
dt.Clear();
ada.Fill(dt);
//Display in Textbox
if (dt.Rows.Count > 0)
{
txtlnid.Text = dt.Rows[0].ItemArray[0].ToString();
admdate.Text = dt.Rows[0].ItemArray[1].ToString();
txtadmamt.Text = dt.Rows[0].ItemArray[2].ToString();
txtadmint.Text = dt.Rows[0].ItemArray[3].ToString();
loandt.Text = dt.Rows[0].ItemArray[4].ToString();
txtlnamt.Text = dt.Rows[0].ItemArray[5].ToString();
txtlnint.Text = dt.Rows[0].ItemArray[6].ToString();
txtsctot.Text = dt.Rows[0].ItemArray[7].ToString();
}
if (cn.State == ConnectionState.Closed)
{
cn.Open();
}
string str;
str = cmd.ExecuteScalar().ToString();
if (str != null)
{
MessageBox.Show("Record Found");
}
else
{
MessageBox.Show("ID not Match");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
推荐答案
也将以下内容附加到您的代码中-
Also append the following to your code -
finally
{
cn.Close();
}
HTH
拉杰夫
如果有帮助,请投票并标记答案为可接受
HTH
Rajeev
Please vote and mark the answer as accepted if this helps
您的连接字符串似乎缺少数据源.请参见此链接,例如连接字符串 [
Your connection string seems to be missing the Data Source. See this link for example connection strings[^]
这篇关于SQL命令未正确结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文