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
Why is ADO.NET serialization slower than ADO ?
what is the difference betwen typed dataset and untyped dataset?in general which dataset can we use in programming?
What is the namespaces being used to access oracle database?
What providers does Ado.net uses?
What is adodb dll?
What is the executescalar method?
What is data relation?
How can we load multiple tables in to dataset?
What is the difference between the clone() and copy() methods of the dataset class?
Why do we serialize data?
What is the difference between data grid and data repeater?
What are the various methods provided by the DataSet object to generate XML?
How would you connect to database using .NET?
Explain the difference in record set and dataset?
Why ca not we use multiple inheritance and garbage collector paralelly in .net?