991ben234anesi345
New Member
There is a problem in the fourth line of code. Can any one tell me what's wrong with it?<BR><BR>Dim objDataSet As New DataSet("dbFridge")<BR>Dim objTable As DataTable = objDataSet.Tables("tblFoodType")<BR>Dim objDataRow As DataRow<BR>objDataRow = objTable.NewRow()<BR>objDataRow("sType_E") = sType_E.Text<BR>objDataRow("sType_C") = sType_C.Text<BR>objTable.Rows.Add(objDataRow)In old VB6 you have to use the command "set" when you are creating a object. Haven't been working with VB.Net, so I don't know if you still have to use the command "set".hi,<BR><BR>Just alter the code, after creating datatable <BR>first add datacolum for that,i think then only we will able to add rows to data table.then add datacolum to the datatable,then add datarow for the datatable.<BR><BR>The modified sample given below<BR>---------------------------------<BR> Dim objDataSet As New DataSet("dbFridge")<BR> Dim objTable As New DataTable()<BR> Dim objcolum As New DataColumn("sType_E")<BR> Dim objcolum1 As New DataColumn("sType_c")<BR> objTable.Columns.Add(objcolum)<BR> objTable.Columns.Add(objcolum1)<BR><BR> Dim objDataRow As DataRow<BR> objDataRow = objTable.NewRow()<BR> objDataRow("sType_E") = "1"<BR> objDataRow("sType_C") = "2"<BR> objTable.Rows.Add(objDataRow)<BR> objTable = objDataSet.Tables("tblFoodType")<BR><BR>hope this will help u..<BR>regards<BR>yesuThanks for your suggestion. The problem is, I already create the table with columns manually in the database. I just want to insert the values into the table. Do you have any idea how to do that?