i want 2 pass values(enterd in textbox)to table in sql
server without using stored procedure in c#.plz tell me
code with an example.
Answer Posted / ranjeet kumar panda
SqlConnection con;
SqlCommand cmd;
SqlDataReader dr;
SQlDataAdapter da;
string sqlstr;
Connection String......
//using DataReader
sqlstr="insert into tablename(Colname) values
("+textBox1.Text+")";
if(con.state==ConnectionState.Open)
con.Close();
cmd.CommandText=sqlstr;
con.Opem();
cmd.ExecuteNonQuery();
//using DataSet
.........
........
da.Fill(ds,"tablename");
DataRow drw=ds.Tables[0].NewRow();
drw[0]=textBox1.Text;
ds.Table[0].Rows.Add(drw);
SqlCommandBuilder cb=new SqlCommandBuilder(da);
da.Update(ds,"tablename");
//Using LinqToSql (.Net 3.5)
DataContextName dc=new DataContextName();
//Lets a Control to bind the data
DataGridView1.DataSource=dc.GetTable<tablename>;
//create an object of class(i.e table)
tablename obj=new tablename();
obj.colname=textBox1.Text;
dc.tablenames.InsertOnSubmit(obj);//'s' in tablenames
//is essential
dc.SubmitChanges();
| Is This Answer Correct ? | 7 Yes | 3 No |
Post New Answer View All Answers
What are the advantages and drawbacks of using ado.net?
What is the maximum pool size in ado.net connection string?
What is a dynaset in access?
What is maximum pool size in ado.net connection string?
how can implement dropdownlist in particular of dataset when try to update?
What is DataReader Object?
What is the current version of entity framework?
Define Execute Scalar?
What is the functionality of data provider in ado.net?
If a table contains 20000 records. In a page at each time 100 records to be displayed.
How to maintain the relation between two tables in ADO.NET?
Why is stored procedure used in ado.net?
List the 4 common ado.net namespaces?
describe the dataset object in ado.net.
What is shadow copy?