MYSQL:
myCommand.Parameters.Clear();
myCommand.CommandText = "SELECT * FROM [table] WHERE [name] LIKE (?)";
myCommand.Parameters.Add(new OdbcParameter(null, txtSearch.Text));
MSSQL:
myCommand.Parameters.Clear();
myCommand.CommandText = "SELECT * FROM [table] WHERE [name] LIKE @.search";
myCommand.Parameters.Add(new SqlParameter("@.search", txtSearch.Text));
Thanks for the reply. Where would I put this code? I'm using MSSql, but I am not using any stored procedures. All my SQL code is on my .aspx page. Should this go somewhere on my .aspx page or in my VB codebehind?
This would go in your code behind, in the onclick method from your button (double click your submit button and you'll go automatically to your onclick method).
Remember the code I gave in the example is C# code, I don't know the correct syntax in VB.net but it should get you started.
This should help:
http://www.asp.net/learn/dataaccess/default.aspx?tabid=63
Cheers
0 comments:
Post a Comment