Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How to creating a SqlCommand Object?

1081


What are two types of transaction supported by ado.net?

951


How can we save all data from dataset?

947


how Sequence to connect and retrieve data from database using dataset?

1232


Explain the difference between an ado.net dataset and an ado recordset?

1012


What is isolation?

975


What is the difference between OLEDB Provider and SqlClient?

949


What is connected architecture in ado.net?

990


What are the core objects of ADO.NET?

991


How to add a javaScript function in a datagrid?

1066


Explain how do you connect to sql server database without using sqlclient?

949


Which control of the BindingNavigator returns the current position within the data source?

1117


What provider ado.net use by default? Explain the role of data provider in ado.net?

931


How can we serialize the dataset object?

963


What is datatable in ado.net?

925