Here is my code im using for testing purposes.
The code above takes forever to complete, i had the same problem with regular ADO and i somehow fixed it. Can anyone help optimize this code so it only takes say .3 seconds like the regualr ADO did?
btw...i have seen a lot of people rave about how ADO.NET is better, so far if you ask me, its a pain in the arse, it takes 5 times the amount of code for me to do the same thing that i could in ADO!!
Thanks!
Code:
Try
Dim sConnectionString As String
sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\DATA;Extended Properties=dBase III"
Dim objConn As New System.Data.OleDb.OleDbConnection(sConnectionString)
objConn.Open()
Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from catxprod", objConn)
Dim ds As New DataSet()
da.Fill(ds, "catxprod")
Dim dt As DataTable = ds.Tables("catxprod")
Dim dr As DataRow = dt.Rows(1)
MsgBox(dt.Rows(1).Item(5))
Dim x As Integer, row As DataRow
Dim strCommand = ("INSERT INTO products( [ID], [catcount] ,[agrpcount] ," & _
"[pgrpcount] ,[order], [code], [name], [thumbnail], [image], [price]" & _
", [cost], [desc], [weight], [taxable], [active]) VALUES (ID)")
Dim strCommand = "INSERT INTO catxprod([cat_id], [product_id], [order]) VALUES (@cat_id, @product_id, @order)"
da.InsertCommand = New OleDb.OleDbCommand(strCommand, objConn)
Dim param As OleDbParameter
@ID Parameter
param = da.InsertCommand.Parameters.Add(New OleDbParameter("@cat_id", OleDb.OleDbType.Integer))
param.SourceColumn = "cat_id"
param = da.InsertCommand.Parameters.Add(New OleDbParameter("@product_id", OleDb.OleDbType.Integer))
param.SourceColumn = "product_id"
param = da.InsertCommand.Parameters.Add(New OleDbParameter("@order", OleDb.OleDbType.Integer))
param.SourceColumn = "order"
Dim autogen = New OleDb.OleDbCommandBuilder(da)
MsgBox(autogen.GetInsertCommand.CommandText)
PB1.Maximum = 5000
PB1.Minimum = 1
Dim x As Integer
For x = 1 To 5000
row = dt.NewRow()
row(0) = 444
row(1) = 345
row(2) = 111111
dt.Rows.Add(row)
da.Update(ds, "catxprod")
PB1.Value = x
Next
The code above takes forever to complete, i had the same problem with regular ADO and i somehow fixed it. Can anyone help optimize this code so it only takes say .3 seconds like the regualr ADO did?
btw...i have seen a lot of people rave about how ADO.NET is better, so far if you ask me, its a pain in the arse, it takes 5 times the amount of code for me to do the same thing that i could in ADO!!
Thanks!
Last edited by a moderator: