Showing posts with label procedurehelp. Show all posts
Showing posts with label procedurehelp. Show all posts

Thursday, March 22, 2012

Cant access sql express stored procedure..help!

Hi everyone, im having alot of trouble trying to execute a stored proc from sql express. heres my code

DbProviderFactory db =DbProviderFactories.GetFactory("System.Data.SqlClient");

using(DbConnection conn = db.CreateConnection()){

ConnectionStringSettings s =ConfigurationManager.ConnectionStrings["constrolservicetest"];

conn.ConnectionString = s.ConnectionString;

conn.Open();

DbCommand cmd = conn.CreateCommand();

cmd.CommandText ="StoredProcedure1";

cmd.CommandType =CommandType.StoredProcedure;

DbParameter param = db.CreateParameter();

param.ParameterName ="@.test";

param.Value = 2;

cmd.Parameters.Add(param);

cmd.ExecuteNonQuery();

}

****************************procedure code***************************

Create PROCEDUREdbo.StoredProcedure1

(

@.testint

)

AS

Update temp

Settest = @.test

******************************************************************

The code just doesn't update. I know my connection string is correct because i got the datareader to work, but i just cant get the stored proc to call. Any help will be greatly appreciated.

Thanks,

-D

That code looks reasonable to me. Are you sure it's being called?