V
vncntj
I have this syntax working perfectly, but I'm trying to apply a stored
procedure instead using
the CommandText (Sql Statement).
// Open connection to the database
string ConnectionString =
@"server=localhost;uid=;pwd=;trusted_connection=true;database=PMAEvents";
con = new SqlConnection(ConnectionString);
con.Open();
// Set up a command with the given query and associate
// this with the current connection.
string CommandText = "SELECT Locations, EventTitle FROM
specialevents WHERE Locations LIKE @Find";
cmd = new SqlCommand(CommandText);
cmd.Connection = con;
// Add LastName to the above defined parameter @Find
//cmd.Parameters.Add(new SqlParameter("@Find",
System.Data.SqlDbType.NVarChar, "Locations")); // The name of the
source column
cmd.Parameters.Add(new SqlParameter("@Find",
System.Data.SqlDbType.VarChar));
// Fill the parameter with the value retrieved
// from the text field
cmd.Parameters["@Find"].Value = txtFind.Text;
// Execute the query
rdr = cmd.ExecuteReader();
procedure instead using
the CommandText (Sql Statement).
// Open connection to the database
string ConnectionString =
@"server=localhost;uid=;pwd=;trusted_connection=true;database=PMAEvents";
con = new SqlConnection(ConnectionString);
con.Open();
// Set up a command with the given query and associate
// this with the current connection.
string CommandText = "SELECT Locations, EventTitle FROM
specialevents WHERE Locations LIKE @Find";
cmd = new SqlCommand(CommandText);
cmd.Connection = con;
// Add LastName to the above defined parameter @Find
//cmd.Parameters.Add(new SqlParameter("@Find",
System.Data.SqlDbType.NVarChar, "Locations")); // The name of the
source column
cmd.Parameters.Add(new SqlParameter("@Find",
System.Data.SqlDbType.VarChar));
// Fill the parameter with the value retrieved
// from the text field
cmd.Parameters["@Find"].Value = txtFind.Text;
// Execute the query
rdr = cmd.ExecuteReader();