Link to home
Start Free TrialLog in
Avatar of detox1978
detox1978Flag for United Kingdom of Great Britain and Northern Ireland

asked on

c# .NET MSSQL: run stored procedure

Hi All,

What is the syntax to run a stored procedure in c#


Thanks
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

SOLUTION
Avatar of Anurag Thakur
Anurag Thakur
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry a little late as its the same link
Avatar of detox1978

ASKER

I've created a stored procedure and tested it works.

I've put together the code snipet below, but get the following error;

"Compiler Error Message: CS0161: 'FeedbackDataAccess.CreateFeedback(string)': not all code paths return a value"


Any ideas?
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //first create the customer
        FeedbackDataAccess.CreateFeedback(txtFeedback.Text);
 
    }
 
 
    public static int CreateFeedback(string myfeedback)
    {
 
        // get a configured DbCommand object
        SqlCommand comm = GenericDataAccess.CreateCommand();
        // set the stored procedure name
        comm.CommandText = "App_AddFeedback";
 
 
        // create a new parameter
        SqlParameter param = comm.CreateParameter();
 
        // declair variable(s) to pass to the stored procedure
        param.ParameterName = "@myfeedback";
        param.Value = myfeedback;
        param.SqlDbType = SqlDbType.Text;
        comm.Parameters.Add(param);
 
        try
        {
            GenericDataAccess.ExecuteNonQuery(comm);
        }
        catch
        {
 
        }
    }

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial