Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...