Use LIKE operator to retrieve data from MS Acess in C#

February 14, 2011 at 11:38 am Leave a comment

Both following codes are the same.

1.Do not use command parameter

string  sql = “select * from table where col like  \”%abc%\”   “;

2.Use command parameter

string sql = “select * from table where col like   ?   ”;

OleDbCommand cmd = new OleDdCommand(sql, conn);

cmd.Parameters.AddWithValue(“col”, “%abc%”);

The second code seems to be the better one :-D !!!

 

Ph.

Entry filed under: programming, Tổng hợp. Tags: .

Web designer vs Web developer Solve “Update requires a valid *Command when passed DataRow collection with modified rows”!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Categories


Follow

Get every new post delivered to your Inbox.