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
What is the use of Dataview?
What is a datareader object?
Which object is used to add relationship between two Datatables?
Which method is used to sort the data in ADO.Net?
What are the namespaces used in ado.net for data access?
What is data reader in ado.net?
What is the use of SqlCommand object?
If we are not returning any records from the database, which method is to be used?
Which is faster datareader or dataadapter?
What is concurrency? How will you avoid concurrency when dealing with dataset? (One user deleted one row after that another user through his dataset was trying to update same row. What will happen? How will you avoid the problem?)
What is the difference between Optimistic and Pessimistic locking?
How to add an aggregate column?
What is the difference between dataset and datatable?
What is csdl entity framework?
Explain executenonquery?