Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
private void txt_Search_TextChanged(object sender, EventArgs e)
       {
           try
           {

               con.Open();
               s = " select R_Number , R.P_id , Patients.P_Name  , 
                   convert(varchar,Date_Reservation,105)as ,  ";
               s = s + " DoctorTest.Doctor_Name , ExamType.Exame_Type, R.Notes
                     ";
               s = s + " from ResrvationData R ";
               s = s + " inner join Patients on R.P_id = Patients.P_id ";
               s = s + " inner join DoctorTest on R.Doctor_id = 
                       DoctorTest.Doctor_id ";
               s = s + " inner join ExamType on R.Exame_id = ExamType.Exame_id 
                       ";
               s = s + " Where R_Number + R.P_id + Patients.P_Name  + 
                       DoctorTest.Doctor_Name +  ExamType.Exame_Type like '%" 
                       + txt_Search.Text + "%' and Date_Reservation = 
                       '" + dateTimePicker1.Text + "' and 
                       ExamType.Exame_Type = '" + textBox1.Text + "'
                       ";
               sdAdapter = new SqlDataAdapter(s, con);
               dt = new DataTable();
               sdAdapter.Fill(dt);
               dataGridView_ReservationList.DataSource = dt;
               con.Close();
           }
           catch
           {
               return;
           }
       }


What I have tried:

i used this select query to search and this error in this column (DoctorTest.Doctor_Name)
Posted
Comments
aarif moh shaikh 17-Feb-16 2:05am    
how you convert name into integer ?
Dj@y 17-Feb-16 2:10am    
there is no way to convert name into the integer, conversion is possible if and only if the data in nvarchar is number.
Dj@y 17-Feb-16 6:34am    
:)
[no name] 17-Feb-16 2:31am    
It seems you are converting string value to integer and it won't happen. By the way what is value you are getting in textBox1.Text and txt_Search.Text

1 solution

You are possibly using the concatenation operator '+' on different data types, i.e. and integer and a string. That's not allowed, see + (String Concatenation) (Transact-SQL)[^].
 
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
Top Experts
Last 24hrsThis month


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