Click here to Skip to main content
15,883,749 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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);
            }
Posted
Updated 9-Mar-11 10:25am
v5
Comments
HimanshuJoshi 9-Mar-11 16:16pm    
Edited to correct pre blocks. What is the exact error message?
Manfred Rudolf Bihy 9-Mar-11 16:27pm    
Edit: Corrected misleading title. Inside the code block OP right behind the line cmd.CommandText = ... OP writes that his SQL statement is causing the error.

Also append the following to your code -

finally
{
 cn.Close();
}




HTH
Rajeev



Please vote and mark the answer as accepted if this helps
 
Share this answer
 
Your connection string seems to be missing the Data Source. See this link for example connection strings[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900