开发者

Error converting data type varchar to bigint

When i use this string as a sql command-string compiler gives me no error:

string sql = "SELECT * FR开发者_如何学编程OM Students WHERE StudentNo='" + T_No.Text + "'";

But, if i use this string (includes '%' character) it says "Error converting data type varchar to bigint":

string sql = "SELECT * FROM Students WHERE StudentNo='%" + T_No.Text + "%'";

What should i change in order to use '%' in my statement?


string sql = "SELECT * FROM Students WHERE convert(nvarchar,StudentNo) LIKE '%" + T_No.Text + "%'";

Note, however, that this is inefficient.


Take a look at the following page.

http://web.archive.org/web/20150519072547/http://sqlserver2000.databases.aspfaq.com:80/how-do-i-search-for-special-characters-e-g-in-sql-server.html

The % sign has a special meaning in SQL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜