MDKIMZEY
asked on
ExecuteNonQuery and ExecuteScalar does not return or throw an error when executing stored proc
I have a SQLEXPRESS database. I am using C# and ADO.net to call a stored procedure. The SQL Stored Procedure has been tested and works as expected.
When the code executes the stored procedure is not called, there is no exception and no error.
I tried the same code with ExecuteScalar() but no difference.
Does anyone see an issue with the code below?
When the code executes the stored procedure is not called, there is no exception and no error.
I tried the same code with ExecuteScalar() but no difference.
Does anyone see an issue with the code below?
private void InsertTGroup(string strTEntry)
{
int nRetCode = 0;
// Build a connection string...
SqlConnectionStringBuilder objConnString = new SqlConnectionStringBuilder();
objConnString.InitialCatalog = "TGroups";
objConnString.DataSource = @"(local)\SQLEXPRESS";
objConnString.IntegratedSecurity = true;
SqlConnection objSqlConn = new SqlConnection(objConnString.ConnectionString);
using (SqlCommand objSqlCmd =
new SqlCommand("InsertTGroup", objSqlConn))
// -----------------------------------------------------------
{
try
{
objSqlCmd.CommandType = CommandType.StoredProcedure;
// Input parameter
SqlParameter objSqlParam = new SqlParameter();
objSqlParam.ParameterName = "@strGroupName";
objSqlParam.SqlDbType = SqlDbType.NVarChar;
objSqlParam.Size = 120;
objSqlParam.SqlValue = strTEntry;
objSqlParam.Direction = ParameterDirection.Input;
objSqlCmd.Parameters.Add(objSqlParam);
nRetCode = objSqlCmd.ExecuteNonQuery();
}
catch (SqlException e)
// -------------------------------------------------------
{
Console.WriteLine(e.Message);
}
}
objSqlConn.Close();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER