转换varchar值时转换失败“医生name1''到数据类型int。在c#中 [英] Conversion failed when converting the varchar value " doctor name1 '' to data type int. in c#

查看:80
本文介绍了转换varchar值时转换失败“医生name1''到数据类型int。在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;
           }
       }





我的尝试:



i使用此选择查询进行搜索并在此列中显示此错误(DoctorTest.Doctor_Name)



What I have tried:

i used this select query to search and this error in this column (DoctorTest.Doctor_Name)

推荐答案

您可能正在使用串联运算符' + '对不同的数据类型,即整数和字符串。这是不允许的,请参阅 +(String Concatenation)(Transact-SQL) [ ^ ]。
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)[^].


这篇关于转换varchar值时转换失败“医生name1''到数据类型int。在c#中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆