February 17th, 2013, 02:08 AM
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 & "'"
MsgBox "Product Updated"
February 17th, 2013, 02:48 AM
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
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.