guys i need ur help i want to insert data directly into the sql table using c# here is my code all that i have been able to do is get the values from the table not insert them i tried to do it this way but apprently there is some thing wrong with this code plz help me out

string sConnectionString = "Data Source=localhost;Initial Catalog=ScratchCardSystem2;Integrated Security=True;pooling=true";
                SqlConnection objConn = new SqlConnection(sConnectionString);

                string query = "SELECT * FROM store_adj_note_detail_1";
                SqlDataAdapter dAdapter = new SqlDataAdapter(query,objConn);

                SqlCommandBuilder cBuilder = new SqlCommandBuilder(dAdapter);
                DataTable dTable = new DataTable();
                //fill the DataTable

                //the DataGridView
                DataGridView dgView = new DataGridView();

                //BindingSource to sync DataTable and DataGridView
                BindingSource bSource = new BindingSource();

                //set the BindingSource DataSource
                bSource.DataSource = dTable;

                //set the DataGridView DataSource
                dgView.DataSource = bSource;

Here is a good tutorial, it's written in but its almost identical to C# because they both use .NET framework classes and namespaces.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.