hi ... how to create the stored procedure?, and how to call the stored procedure in c# ?....

Recommended Answers

All 4 Replies

***what is MyGrid referring to in this code ^^^ ???***
Answer: A DataGridView

***hi ... how to create the stored procedure?, and how to call the stored procedure in c# ?.... ***
Answer: Creating a stored procedure is done at the SQL Server using the tools provided by the database vendor. DaniWeb has a forum for SQL for this question, or any one of the public tutorials and MSDN tutorials on how to create a stored procedure.
Calling a stored procedure is done by its name. See the example near the top of this thread. The SqlCommand instance contains the name of the stored procedure to be executed. It is also set to be CommandType.StoredProcedure. You can pass parameters to it by adding to the Parameters collection as shown in the example above. There are other ways to add parameters, that is just the shortest syntax.
Hope this answered your questions, or put you on the path to meet your goal,
Cheers,
Jerry

u cal create storeprocedure in sql server by
CREATE PROCEDURE statement

Eg:-
create procrdure data @name varchar(10), @suraname varchar(10)
as
begin
inert into employee values (@name,@surname)
end

and then execute this by F5

then after check into Programibility and ito that Store Procedure

and into the C#

you can use it like

cmd=System.Data.Sqlclient.SqlCommand("data",con);//data is storeprocedurs name and con is connection object
cmd.CommandType=commandtype.StoreProcedure();
cmd.parameters.AddWithValues(@name,txtname.Text);// passing parameters
cmd.Parameters.AddWithValues(@suraname,txtsuraname.Text);
cmd.ExecuteNonQuery();

Sorry for any confusion. Somehow, DaniWeb spawned this new thread from another thread that is real old. I was answering a post that was sent to me today, but DaniWeb also moved that request off to somewhere else, and posted my reply here.
Anyway, you can ignore this thread

You just need to implement store procedure as you do it sql other queries
you need to write a code for implementing store procedure like:

Button1_Click(object sender, EventArges e)
{
//create sqlconnection and open it.
Sqlcommand cmd=new Sqlcommand("dbo.Myprocedure",connectionObject);

cmd.CommandType=CommandType.StoreProcedure();
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.