5 Replies - 1341 Views - Last Post: 13 March 2013 - 09:25 PM Rate Topic: -----

#1 kalkol  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-March 13

error code

Posted 13 March 2013 - 06:21 AM

i use vb6 and my sql give me error
can some one look at it and tell me what i am doing wrong?
mysql = ("select *  from test where id >=" & Text1.Text And products = " & Text3.Text & ") 

this code give me errore
mysql = "select *  from test where id >=" & Text1.Text And products = '" & Text3.Text & "'"

and try this but give me error too
mysql = "select *  from test where id >=" & Text1.Text And (products = '" & Text3.Text & "')"

and try this but give me error too

Is This A Good Question/Topic? 0
  • +

Replies To: error code

#2 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: error code

Posted 13 March 2013 - 06:33 AM

perhaps if you told us what the error is, it would be easier to help you.

Looking at your code, check out where you have quotes, it appears you're missing some!
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3182
  • View blog
  • Posts: 10,659
  • Joined: 12-December 12

Re: error code

Posted 13 March 2013 - 06:35 AM

In each case you are missing a double-quote ".

Re-writing the expression several times though will not help you to fix it. Stick with one and get the quotes in the right place. If the expression itself is then found to be incorrect then you can work to find the correct expression.
Was This Post Helpful? 0
  • +
  • -

#4 kalkol  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-March 13

Re: error code

Posted 13 March 2013 - 08:08 AM

View Postmaj3091, on 13 March 2013 - 06:33 AM, said:

perhaps if you told us what the error is, it would be easier to help you.

Looking at your code, check out where you have quotes, it appears you're missing some!

Private Sub Form_Load()
Set mydatabase = OpenDatabase(App.Path + "\go1.mdb", False, False)

End Sub

Private Sub Command1_Click()
Dim mysql As String
Dim rs As Recordset
Dim x As Integer
x = 0


[color="#FFFF00"]  mysql = "select *  from test where id >=" & Text1.Text And products = '" & Text3.Text & "'"[/color]
    
       
   Set rs = mydatabase.OpenRecordset(mysql)
  
   Do While Not rs.EOF
   x = rs!qty + x
   Text2.Text = x
        rs.MoveNext
        Loop
        
        
End Sub


error Message is syntax error
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3182
  • View blog
  • Posts: 10,659
  • Joined: 12-December 12

Re: error code

Posted 13 March 2013 - 08:25 AM

Try this:

 mysql = "select *  from test where id >=" & Text1.Text & " And products = '" & Text3.Text & "'"

Was This Post Helpful? 0
  • +
  • -

#6 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 572
  • View blog
  • Posts: 2,985
  • Joined: 19-May 09

Re: error code

Posted 13 March 2013 - 09:25 PM

The " and products = '" is part of your SQL command, so it needs to be a literal string here. Andrew has given you the answer; I hope you will still go to the trouble of learning how to avoid making that sort of mistake in future.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1