insert file

fresh1207

Member
Joined
Jan 5, 2007
Messages
6
Programming Experience
1-3
I am inserting text files into MySQL using vb.net. However, when I insert the files in to the database it only insert every other file. For example, it will insert one file then the next row will be zeros. Does any one know why it might be doing this. Here is some code:

Dim myConnString AsString = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=192.168.1.27;" & _
"DATABASE=testship;" & _
"USER=?;" & _
"PASSWORD=?;" & _
"OPTION=3;"
Dim MyConnection AsNew Odbc.OdbcConnection(myConnString)
MyConnection.Open()

Dim MyCommand AsNew Odbc.OdbcCommand("INSERT INTO ls_orderitems (OrderDate, OrderCustomer, OrderAcctNum, OrderType, OrderSoNum, OrderItemPartNum, OrderItemPartDesc, OrderItemQty, OrderItemQtyRec, OrderItemQtyDtRec, OrderItemBO, OrderItemBODt,OrderItemCanceled, OrderItemCanceledDt, OrderItemNotes, OrderItemPONum, OrderItemRetailPrice, OrderItemSalePrice, Status, InsertDate) VALUES ('" & OrderDate & "','" & OrderCustomer & "','" & OrderAcctNum & "','" & OrderType & "','" & OrderSoNum & "','" & OrderItemPartNum & "','" & OrderItemPartDesc & "','" & OrderItemQty & "','" & OrderItemQtyRec & "','" & OrderItemQtyDtRec & "','" & OrderItemBO & "','" & OrderItemBODt & "','" & OrderItemCanceled & "','" & OrderItemCanceledDt & "','" & OrderItemNotes & "','" & OrderItemPONum & "','" & OrderItemRetailPrice & "','" & OrderItemSalePrice & "','" & Status & "','" & InsertDate & "')")

MyCommand.Connection = MyConnection
MyCommand.ExecuteNonQuery()
MyConnection.Close()

 
I believe the relevant part of the code is not shown. How are you setting the variables used as values in your SQL statement? (OrderDate, OrderCustomer, OrderAcctNum, ...)

Your query speaks of files; what files are you speaking of? They are not shown in the code above.

Just a note: as a general rule, the code you place between opening and closing the connection should only be there if an open connection is needed. What I mean by that is you should move the line "MyConnection.Open()" down after instantiating and setting the command property of the command object.
 
Back
Top