alleho Posted February 10, 2004 Posted February 10, 2004 I have this code that writes data to a datatable from a form. The insert works fine but when it does an update Ii get a Syntax error. Couldn't see why so I added the simple code and remed my original code out. still get the message!!!. The DB is Foxpro so it will not generate an update command for me. Dim id As String Dim Desc As String Dim productid As Integer Dim producttypeid As Integer Dim brandid As Integer Dim codetype As Integer Dim minstocktotal As Decimal Dim minstockdepot1 As Decimal Dim status As String Dim value As Decimal id = txtECAS.Text Desc = txtDescription.Text productid = CboProduct.SelectedValue producttypeid = CboProductType.SelectedValue brandid = cboBrand.SelectedValue codetype = CboCodeType.SelectedValue status = cboStatus.Text minstocktotal = txtMinStockTotal.Text minstockdepot1 = txtMinStockDepot1.Text value = txtValue.Text Dim Cmmtrans As New OleDb.OleDbCommand Dim Tranin As OleDb.OleDbTransaction Dim CnnUserman As OleDb.OleDbConnection Dim sqlstr As String CnnUserman = OleDbConnection1 CnnUserman.Open() Cmmtrans.Connection = CnnUserman Tranin = CnnUserman.BeginTransaction() ' insert new record If processtype = 1 Then sqlstr = "INSERT INTO tblstock (ecas, description, productid, producttypeid, brandid, codetypeid,minstocktotal,minstockdepot1,status,value) " & _ "VALUES ('" & id & "','" & Desc & "'," & productid & "," & producttypeid & "," & brandid & "," & codetype & "," & minstocktotal & "," & minstockdepot1 & ",'" & status & "'," & value & ")" 'AMENDMENT NOT WORKING ElseIf processtype = 2 Then ' Me.BindingContext(DsStock2, "viewstock").Position += 1 ' sqlstr = "UPDATE tblstock SET (ecas='" & id & "'," & "description='" & Desc & "'," & " productid =" & productid & "," & "producttypeid=" & producttypeid & "," & "brandid=" & brandid & "," & "codetypeid=" & codetype & "," & "minstocktotal=" & minstocktotal & "," & "minstockdepot1=" & minstockdepot1 & "," & "status='" & status & "'," & "value=" & value & ")" & " WHERE(ecas=" & "'" & id & "')" sqlstr = "UPDATE TBLSTOCK SET (BRANDID=3)WHERE (ecas='8099563')" MessageBox.Show(sqlstr) End If Cmmtrans.CommandText = sqlstr Cmmtrans.Transaction = Tranin Cmmtrans.ExecuteNonQuery() Tranin.Commit() Thanks in advance Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.