run time error column 0. can not be found below is my code
string Connectiostring = (string) ConfigurationSettings.AppSettings ["NorthwindConnectionString"]; SqlConnection conn = New SqlConnection (ConnectIostring); SqlCommand CMD = New SQL Commands ("Select from Employee", Con); Conn.Open (); SqlDataAdapter Adapter = New SqlDataAdapter (CMD); Dataset data = new dataset (); Adapter.Fill (data, "employee"); Data.Tables ["Staff"] Columns.Add ("Testcolumn") .; Datatable T1 = new datatable ("employee"); Dataraw Newov = T.NewRow (); New [0] = "10"; \\ This line is new to me [1] = "Pradeep"; New [2] = "Kumar"; Data.Tables ["Employee"] Rows.Add (newrow). GridView2.DataSource = Data; GridView2.DataBind ();
Please thank me,
I think it might Is really your problem
DataTable t1 = New DataTable ("Employee")This creates a new table object that is not part of your dataset.
then you should replace it with
DataTable t1 = data.Tables ["employee"]
which becomes The table from the dataset and the t1 variable in that table indicates
Comments
Post a Comment