Call a stored procedure from ado.net and pass parameter to it ?
Answer Posted / dinesh gupta
string
ConnectionString= "server="+DatabaseSrvr+";database="+Datab
aseNam+";user id="+DatabaseUsr+";password="+DatabasePass
;
Sqlconnection Cn = new SqlConnection(ConnectionString);
Cn.Open();
SqlCommand cmd = new SqlCommand("PROCNAME", Cn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter p = new SqlParameter();
p = new SqlParameter();
p.ParameterName = "@parameter1";
p.SqlDbType = SqlDbType.VarChar;
p.Size = 10;
p.Value = "abc";
p.Direction = ParameterDirection.Input;
cmd.Parameters.Add(p);
p = new SqlParameter();
p.ParameterName = "@parameter2";
p.SqlDbType = SqlDbType.Int;
p.Value = Convert.ToInt16(textbox.text);
p.Direction = ParameterDirection.Input;
cmd.Parameters.Add(p);
cmd.ExecuteNonQuery();
| Is This Answer Correct ? | 8 Yes | 3 No |
Post New Answer View All Answers
differance between ADO vs ADO.Net?
Define data adapter?
What is the return type of executescalar?
What are the advantage of ado.net?
How do you connect to sql server database without using sqlclient?
Is ado.net dead?
What are the advantages and drawbacks of using ado.net?
What are the different methods available under the sqlcommand class to access the data?
Explain how to create dynamic gridview?
How to add an aggregate column?
Which object of ado contains datarow datacolumn collection?
What Is Difference Between Ado And Ado.net?
Can we do database operations without using any of the ado.net objects?
What is aggregate root?
What is fill method in ado.net?