Inclusion of a new row in the database, works for one table and not for an other !

khalid71

New member
Joined
Jun 15, 2006
Messages
1
Programming Experience
Beginner
As explained earlier I tried to insert a new row with the following code it is working perfectly for the table "liste article"
VB.NET:
ligart = dataset.Tables("liste article").NewRow
'ligart("code") = "test"
'ligart("CODEBARRE") = "Test"
'ligart("nom") = "test"
'ligart("TYPE") = "U"
'dataset.Tables("liste article").Rows.Add(ligart)
'cmdbuild2 = New OdbcCommandBuilder(reqarticle)
'Try
' reqarticle.Update(dataset, "liste article")
'Catch ex As Exception
' MsgBox(ex.message)
'End Try
'dataset.Clear()
'charger()

but when I try to do the same with the table "liste etcdeclient" its not working try to explain me the reason, if anyone can help me.
VB.NET:
liget = dataset.Tables("liste etcdeclient").NewRow
'ligdefste = resreqdefste.Rows(0)
'liget("RTCFIELD1") = 1234 'Trim(Mid(Lignes(i), 44, 35))
'liget("codedocutil") = 315 ' ligdefste("numclientcde") + 1
liget("code") = 800
'liget("type") = "CC"
'liget("datedoc") = Today
liget("tarif") = 1
'liget("CategorieAV") = "0"
'liget("Depot") = "DP"
'liget("calculTVA") = True
'liget("GestionTPF") = True
'liget("PieceTrans") = False
'liget("PieceEdit") = False
dataset.Tables("liste etcdeclient").Rows.Add(liget)
cmdbuild2 = New OdbcCommandBuilder(reqetclient)
reqetclient.InsertCommand = cmdbuild2.GetInsertCommand
Try
reqetclient.Update(dataset, "liste etcdeclient")
Catch ex As Exception
MsgBox(ex.Message)
End Try
dataset.Clear()
charger()
 
Last edited by a moderator:
im surprised the first code works = the line that does the update is commented out! :)


i would take a look at the insert queries themselves, as what you have written here looks reasonable enough. break the code just after you create InsertCOmmand, and ask it what the commandtext actually is
 
It won't make any difference, but just for future ref i would refrain from using words like dataset as variables. It can make for confusing reading, and it's just not best practice.
 
Back
Top