sql命令出错 [英] error on sql command
问题描述
string str =select * from Employee_Details where Employee_Name =''+ txt_serch_by.Text +'';
SqlCommand objgcmd = new SqlCommand(str,ObjCon);
SqlDataAdapter sda = new SqlDataAdapter(objgcmd);
DataTable dt1 = new DataTable();
sda.Fill(dt1 );
来自此代码的
收到类似-----的错误消息 - 当前上下文中不存在名称''txt_serch_by'-------
如何克服这个错误
string str = "select * from Employee_Details where Employee_Name=''" + txt_serch_by.Text + "''";
SqlCommand objgcmd = new SqlCommand(str, ObjCon);
SqlDataAdapter sda = new SqlDataAdapter(objgcmd);
DataTable dt1 = new DataTable();
sda.Fill(dt1);
from this code am getting a error message like-----The name ''txt_serch_by'' does not exist in the current contex-------
how to overcome this eror
推荐答案
它似乎没有正确添加Textboxtxt_serch_by或它不存在。
请检查是否存在或者请提供设计代码。
its seems that Textbox "txt_serch_by" is not added on form correctly or it is not present.
Please check whether is present or else please provide the design code.
请尝试将txt_serch_by与字符串格式的一个变量一起存储并从中读取那个变量。
Please try it, by storing "txt_serch_by" with one variable in string format and read from that variable.
好像你的txt_serch_by未正确注册到设计师页面。
删除文本框并重新添加。
It seems that your txt_serch_by not properly registered to designer page.
remove the textbox and add it again.
这篇关于sql命令出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!