Why is there a need to define a table when the table already exists in the database. Doesnt the data adapter / dataset / datatable pick up the table's structure by itself when its fetching data from database ?
On Mar 26, 10:05 pm, Stephen Russell <[email protected]> wrote: > On Fri, Mar 26, 2010 at 7:17 AM, Faraz Azhar <[email protected]> wrote: > > Hello > > > I'm totally lost in ADO.NET ! I'm very experienced with VB6 + VB.NET > > along with ADO. But now im trying to develop code for ADO.NET using > > VB.NET working with Access 2007 database. > > > My simplest goal is to add a row to my table. It's giving me a > > headache. This is my code: > > > Dim dAdapter = New OleDbDataAdapter("SELECT * FROM [Files]", con) > > Dim dSet As New DataSet > > dAdapter.Fill(dSet) > > > Dim dTable As DataTable = dSet.Tables(0) > > ------------- > > You are defining no structure to your containers and then attempting > to fill them. > > First define the Table(s) by adding the columns, or fetch data to do > that step for you. > > Once your table is defined. > > DataRow dr = dTable.NewRow() > > now do this: > dRow("FilePath") = "C:\MyFile.txt" > dRow("Size") = "1024" > dTable.Rows.Add(dRow) > > HTH > > -- > Stephen Russell > > Sr. Production Systems Programmer > CIMSgts > > 901.246-0159 cell To unsubscribe from this group, send email to dotnetdevelopment+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
