[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

(Scott Rassbach)

12/26/2002 1:36:00 PM

I have a good connection to the AS400 using the ODBC.NET adapters. I
can get whatever records I want. However, In the example below, I
can't figure out how to write the Insert String, so that it will work
for multiple records and the general "Update" method of the data
adapter will work.

My tables have primary keys, but that information doesn't seem to come
across with the ODBC .NET classes. The ODBCCommandBuilder doesn't
return any kind of insert information. Setting the primary key in my
VB.NET app has no effect.

I'm trying to insert records into Table "Table1" in partition
"TestDTA".

Suggestions on Insert strings would be appreciated. If I haven't
given enough infomation, I will gladly provide more. Thank you.


Public Function AddRecords(ByVal MyDataset As DataSet, ByVal
sInsertString As String) As Boolean

Dim MyCommand as ODBCCommand = New ODBCCommand()
Dim MyConnection as ODBCConnection = new
ODBCConnection(sGlobalConnectionString)
dim MyDataAdapter as ODBCDataAdapter = New ODBCDataAdapter()


Try
MyCommand.CommandText = sInsertString
MyCommand.Connection = MyConnection
MyDataAdapter.InsertCommand = MyCommand
MyConnection.Open()
MyDataAdapter.Update(MyDataset)

Return True
Catch e As Exception
Debug.WriteLine(e.ToString)
Return False
Finally
MyConnection.close()
End Try
1 Answer

(Scott Rassbach)

12/26/2002 1:36:00 PM

0

scottrassbach@go.com (Scott Rassbach) wrote in message news:<d0273969.0209110644.3205a92@posting.google.com>...

I have a follow up

I've tried an insert command with the following string:
"INSERT INTO TESTDT.MYTABLE( A5AN8 , A5LITM , A5Y56CPN , A5Y56SKU ,
A5UPRC , A5ITEMDES, A5UPCN , A5Y56AFG , A5Y56AYD , A5Y56ADD ,
A5ITEMNUM ) VALUES ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )"

It seems to work (I don't get any exceptions) but the update doesn't
happen.

Any ideas?