Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
string CS = ConfigurationManager.ConnectionStrings["SampleConnectionString"].ConnectionString;
        SqlDataAdapter da; Dataset ds; DataRow Rec; SqlCommandBuilder bldr;
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                Rec = ds.Tables[0].NewRow();//here when i writing the ds.Tables[] here iam getting the red curling lines with above mentioned error.
                Rec[0] = TextBox1.Text;
                Rec[1] = TextBox2.Text;
                Rec[2] = TextBox3.Text;
                Rec[3] = TextBox4.Text;
                Rec[4] = TextBox5.Text;
                ds.Tables[0].Rows.Add(Rec);
                Console.WriteLine("Record Inserted");               
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
Posted
Updated 25-Mar-14 18:43pm
v3
Comments
Richard MacCutchan 26-Mar-14 4:58am    
You have edited your question but you have not added any more information. Try copying and pasting the exact error message you see, and show us any more of the code that may be relevant.

1 solution

That code does not look to be complete,, see http://msdn.microsoft.com/en-us/library/system.data.dataset.aspx[^] for details on using a DataSet correctly.
 
Share this answer
 

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