Update DB Using VB 6.0
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Update DB Using VB 6.0

  1. #1
    Join Date
    Feb 2013

    Update DB Using VB 6.0

    Hello Guys, I need Your help.. Because my Code not Working,, VB 6.0 Says: Type Mismatch.

    Private Sub Command3_Click()
    Dim update As Integer
    update = "UPDATE [ProductInfo] SET Price = '" & txtPrice.Text & "' , Quantity= '" & txtQty.Text & "' where BarCode= '" & txtBarCode.Text & "'"
    acd.Execute update
    MsgBox "Product Updated"
    End Sub

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: Update DB Using VB 6.0

    Are your database fields defined as text or numeric? Fields like price and qty one would think would be numeric or should be anyway.

    If they are then you have another error which has not yet popped up .... syntax error in query expression. 's are used around Text fields but not used for Numeric fields.

    As to your error you have defined update as Integer but are trying to use it as a string which causes a type mismatch... i.e. You are trying to put one type of data in a variable which you have told VB should be getting a different type of data so the types do not match. Change your dim to the correct type and that error will go away.
    Always use [code][/code] tags when posting code.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This a Codeguru.com survey!

On-Demand Webinars (sponsored)