Hey, I need someone to put me out of my misery here..
I am relatively new to VB.NET (old hand at VB6)
So, I have a project where I am taking large, bloated CSV's and importing them into an access database. I understand that filling the CSV data into a DataSet, and then updating the database with the Dataset is a pretty fast way to do it.. Great.. Except all the examples and reading I do about it still leave me with code that is not working(but not erroring either)... So here is where you can collectively tell me what I am doing wrong..
I Create my DataSet:
Dim Conn AsNew OleDb.OleDbConnection(mvarstrConnStr)
Conn.Open()
Dim da AsNew OleDb.OleDbDataAdapter("Select * FROM index_data", Conn)
Dim ds AsNew Data.DataSet("CSV")
Dim dsTbl As Data.DataTable
Dim cb AsNew OleDb.OleDbCommandBuilder(da)
Dim cmd As OleDb.OleDbCommand
cmd = cb.GetInsertCommand()
Then, I Create My DataSet Columns:
'Create DataSet Header
dsTbl = ds.Tables.Add("index_data")
dsTbl.Columns.Add("FileID", GetType(Long))
dsTbl.Columns.Add("Type", GetType(String))
dsTbl.Columns.Add("Count", GetType(Double))
dsTbl.Columns.Add("Size", GetType(Double))
For I = 0 To 120
dsTbl.Columns.Add("C" & I, GetType(Double))
Next
For I = 0 To 120
dsTbl.Columns.Add("M" & I, GetType(Double))
Next
Then I add My Data:
Dim DR As DataRow
For lngCntr = 1 To lngRows - 1
Next
Then, I commit My changes and Update:
dsTbl.AcceptChanges()
lngRowsIns = da.Update(dsTbl)
Now the problem: No Error, No Records Inserted!
Any Ideas?
Thanks
Andrew
I am relatively new to VB.NET (old hand at VB6)
So, I have a project where I am taking large, bloated CSV's and importing them into an access database. I understand that filling the CSV data into a DataSet, and then updating the database with the Dataset is a pretty fast way to do it.. Great.. Except all the examples and reading I do about it still leave me with code that is not working(but not erroring either)... So here is where you can collectively tell me what I am doing wrong..
I Create my DataSet:
Dim Conn AsNew OleDb.OleDbConnection(mvarstrConnStr)
Conn.Open()
Dim da AsNew OleDb.OleDbDataAdapter("Select * FROM index_data", Conn)
Dim ds AsNew Data.DataSet("CSV")
Dim dsTbl As Data.DataTable
Dim cb AsNew OleDb.OleDbCommandBuilder(da)
Dim cmd As OleDb.OleDbCommand
cmd = cb.GetInsertCommand()
Then, I Create My DataSet Columns:
'Create DataSet Header
dsTbl = ds.Tables.Add("index_data")
dsTbl.Columns.Add("FileID", GetType(Long))
dsTbl.Columns.Add("Type", GetType(String))
dsTbl.Columns.Add("Count", GetType(Double))
dsTbl.Columns.Add("Size", GetType(Double))
For I = 0 To 120
dsTbl.Columns.Add("C" & I, GetType(Double))
Next
For I = 0 To 120
dsTbl.Columns.Add("M" & I, GetType(Double))
Next
Then I add My Data:
Dim DR As DataRow
For lngCntr = 1 To lngRows - 1
DR = dsTbl.NewRow()
IfNot DR IsNothingThen
DR(
"FileID") = intID
DR("Type") = Left(strArry(lngCntr, 0), 255)
DR("Count") = strArry(lngCntr, 1)
DR("Size") = strArry(lngCntr, 2)
For lngAttr = 3 To lngCols - 1
DR(CInt(lngAttr) + 1) = strArry(lngCntr, lngAttr)
Next
dsTbl.Rows.Add(DR)
EndIf
dsTbl.AcceptChanges()
lngRowsIns = da.Update(dsTbl)
Now the problem: No Error, No Records Inserted!
Any Ideas?
Thanks
Andrew