Wednesday, January 11, 2006
SQL Connection/////////// using System.Data; using System.Data.SqlClient; /////////// SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]); SqlCommand myCommand = new SqlCommand("sp_UpdateUser", myConnection); myCommand.CommandType = CommandType.StoredProcedure; SqlParameter parameterItemID = new SqlParameter("@ItemID", SqlDbType.Int, 4); parameterItemID.Value = itemId; myCommand.Parameters.Add(parameterItemID); // out parameters to Sproc SqlParameter paramRoles = new SqlParameter("@AccessRoles", SqlDbType.NVarChar, 256); paramRoles.Direction = ParameterDirection.Output; myCommand.Parameters.Add(paramRoles); myConnection.Open(); try { myCommand.ExecuteNonQuery(); //or // SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection); // return result } catch{} finally { if (myConnection.State == ConnectionState.Open) { myConnection.Close(); } } |
About Me
LinksPrevious Posts
Archives |
0 Comments:
Post a Comment
<< Home