Click here to Skip to main content
15,914,924 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
How can we insert a value in sql server through asp.net web application.
Posted

Read about ADO.NET here and it will help you. Look at these:
MSDN: ADO.NET[^]
MSDN: Accessing Data with ADO.NET[^]
The C# Station ADO.NET Tutorial[^]
Using ADO.NET for beginners[^]
 
Share this answer
 
Comments
RaviRanjanKr 1-May-11 13:03pm    
Good Collection of Links! My 5 :)
Sandeep Mewara 1-May-11 13:05pm    
Thanks.
Read about ADO.Net on MSDN. There are a lot of examples on the web for it.
 
Share this answer
 
Depending on your application, there are a variety of ways.
Here is a relatively generic method:
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand com = new SqlCommand("INSERT INTO myTable (myColumn1, myColumn2) VALUES (@C1, @C2)", con))
        {
        com.Parameters.AddWithValue("@C1", myValueForColumn1);
        com.Parameters.AddWithValue("@C2", myValueForColumn2);
        com.ExecuteNonQuery();
        }
    }
 
Share this answer
 
        public SqlConnection con;
        public SqlCommand cmd;
        public SqlDataAdapter adp;
        public DataSet ds;

public void connection()
        {
            con = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=practice;Data Source=HOME-78F3176757");
            con.Open();
        }

        public DataSet filldata(string mystring)
        {
            connection();
            adp = new SqlDataAdapter(mystring, con);
            ds = new DataSet();
            adp.Fill(ds);
            return ds;
        }


Place this in a class file and call filldata(). And from there pass select query.

Hope this can help you.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900