如何解决此错误信息? [英] How to solve this error message?

查看:89
本文介绍了如何解决此错误信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
按学生证搜索时查询表达式存在问题
和关于错误运算符的错误弄乱(查询表达式"student.id_civil_st like123456"中的语法错误(缺少运算符)
如以下代码所示:

Hii,everyone
there is aproblem in query expression when search by student id''s
and error messing about missing operator (Syntax error(missing operator)in query expression''student.id_civil_st like123456''
as in this code :

string conString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=..\\..\\org.accdb";
           OleDbConnection con = new OleDbConnection(conString);
           DataTable dt = new DataTable();
           OleDbDataAdapter oda = new OleDbDataAdapter("SELECT * FROM student WHERE student.id_civil_st like" + int.Parse(textBox1.Text), con);
           oda.Fill(dt);
           dataGridView1.DataSource = dt;

推荐答案



搜索ID时请使用引号,
查询应该是这样,
Hi,

Use quotation mark when searching for ID,
Query should be like,
OleDbDataAdapter oda = new OleDbDataAdapter("SELECT * FROM student WHERE student.id_civil_st like ''" + int.Parse(textBox1.Text), con) + "''";


另一个样本,


Another Sample,

Select * from student where student.id_civil_st like '123456';


希望这能解决您的问题


Hope this resolve your issue


LIKE确定给定的字符串是否匹配指定的模式.
LIKE determines whether or not a given character string matches a specified pattern.


OleDbDataAdapter oda = new OleDbDataAdapter("SELECT * FROM student WHERE student.id_civil_st like % '"+ int.Parse(textBox1.Text)+"' ", con);


这篇关于如何解决此错误信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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