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
How to creating a SqlCommand Object?
What are two types of transaction supported by ado.net?
How can we save all data from dataset?
how Sequence to connect and retrieve data from database using dataset?
Explain the difference between an ado.net dataset and an ado recordset?
What is isolation?
What is the difference between OLEDB Provider and SqlClient?
What is connected architecture in ado.net?
What are the core objects of ADO.NET?
How to add a javaScript function in a datagrid?
Explain how do you connect to sql server database without using sqlclient?
Which control of the BindingNavigator returns the current position within the data source?
What provider ado.net use by default? Explain the role of data provider in ado.net?
How can we serialize the dataset object?
What is datatable in ado.net?