Connection to SQL

  • Thread starter Thread starter David Lozzi
  • Start date Start date
System.Data.SqlClient NameSpace.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
//This code inserts, updates or deletes a record(s) in a table using a
stored procedure with a single parameter.
//It would need to be modified for a Select statement that retrieved
records.

SqlConnection sqlConn = new SqlConnection("your connection string goes
here");
sqlConn.Open();
SqlCommand sqlComm = new SqlCommand("Your_stored_procedure_name", sqlConn);
SqlParameter prm1 = new SqlParameter("@my_prm",varchar,10);
prm1.value = "neat";
sqlComm.Parameters.Add(prm1);
sqlComm.CommandType = CommandType.StoredProcedure;
Int32 intNumberOfRecordsAffected = sqlComm.ExecuteNonQuery();
sqlConn.Close();

Hope this helps.

Mark
www.dovetaildatabases.com
 
If i put System.Data.SqlClient. infront of it, it works fine. How can I
'declare' this for the entire doc?
 
Back
Top