tags:

views:

22

answers:

1

how to add.paramete i use

i have to insert multi value for making submition form

string connectionString12 = ConfigurationManager.ConnectionStrings["mobile_db"].ConnectionString;
        OleDbConnection con = new OleDbConnection(connectionString12);
        OleDbCommand cmdinsert = new OleDbCommand("insert into brand_tbl (brand_name)values(@2GNetwork)", con);
        Parameter ab = new Parameter();
A: 

I'm not sure I completely understand your question. You don't need parameters unless you are calling stored procedures. If you are passing in a SQL query, then you can pass in arguments in a string.Format() perhaps.

(the below example was adapted from MSDN)

string customerId = "NWIND"
string companyName = "Northwind Traders";

OleDbConnection myConnection = new OleDbConnection(myConnectionString);
string myInsertQuery = string.Format("INSERT INTO Customers (CustomerID, CompanyName) Values('{0}', '{1}')", customerId, companyName);
OleDbCommand myCommand = new OleDbCommand(myInsertQuery);
myCommand.Connection = myConnection;
myConnection.Open();
myCommand.ExecuteNonQuery();
myCommand.Connection.Close();

However, if you wish you call a stored procedure instead, this is how you would do it with OleDB:

(below example was adapted from MSDN)

OleDbConnection myConnection = new OleDbConnection(myConnectionString);
OleDbCommand salesCMD = new OleDbCommand("SalesByCategory", nwindConn);
salesCMD.CommandType = CommandType.StoredProcedure;
OleDbParameter myParm = salesCMD.Parameters.Add("@CategoryName", OleDbType.VarChar, 15);
myParm.Value = "Beverages";
myConnection.Open();
OleDbDataReader myReader = salesCMD.ExecuteReader();
myConnection.Close();
JohnB