SQL queries in VB 6.0

problem with SQL querry

Page 1 of 1

6 Replies - 894 Views - Last Post: 30 October 2009 - 10:12 AM Rate Topic: -----

#1 dimbil  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-October 09

SQL queries in VB 6.0

Posted 29 October 2009 - 08:27 AM

Dear Sir,

I am having a problem with an SQL querry in Visual basic 6.0

What I want to do is to get results either when Name1="ALFA" either when (Name1="BHTA" and date1=date1)
Could you please help me and tell me what is wrong in the following code?

Set WS = DBEngine.Workspaces(0)
Set Db = WS.OpenDatabase(App.Path & "\Database\" & dbname _
, False, False, ")

Set DBRecord = Db.OpenRecordset("Select * from " & "[" & tblname & "]" & " where (Name1= 'ALFA') Or ((name1= 'BHTA') AND (date1 = #" & stDate & "#))")

Sincerely yours,
Bill Dimitriou

Is This A Good Question/Topic? 0
  • +

Replies To: SQL queries in VB 6.0

#2 olibenu  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 45
  • View blog
  • Posts: 537
  • Joined: 31-December 08

Re: SQL queries in VB 6.0

Posted 29 October 2009 - 08:55 AM

try leaving out the # signs
Was This Post Helpful? 0
  • +
  • -

#3 dimbil  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-October 09

Re: SQL queries in VB 6.0

Posted 29 October 2009 - 11:01 AM

View Postdimbil, on 29 Oct, 2009 - 07:27 AM, said:

Dear Sir,

I am having a problem with an SQL querry in Visual basic 6.0

What I want to do is to get results either when Name1="ALFA" either when (Name1="BHTA" and date1=date1)
Could you please help me and tell me what is wrong in the following code?

Set WS = DBEngine.Workspaces(0)
Set Db = WS.OpenDatabase(App.Path & "\Database\" & dbname _
, False, False, ")

Set DBRecord = Db.OpenRecordset("Select * from " & "[" & tblname & "]" & " where (Name1= 'ALFA') Or ((name1= 'BHTA') AND (date1 = #" & stDate & "#))")

Sincerely yours,
Bill Dimitriou



View Postolibenu, on 29 Oct, 2009 - 07:55 AM, said:

try leaving out the # signs



Thank you for your help, but following your suggestion didn't get the results yet
Was This Post Helpful? 0
  • +
  • -

#4 vb5prgrmr  Icon User is offline

  • D.I.C Lover

Reputation: 109
  • View blog
  • Posts: 1,016
  • Joined: 21-March 09

Re: SQL queries in VB 6.0

Posted 29 October 2009 - 07:36 PM

No need for brackets around table name unless table name has a space in its name. If the pound symbol (#) does not work, try single ticks ('). (Long shot...)...



Good Luck
Was This Post Helpful? 0
  • +
  • -

#5 dimbil  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-October 09

Re: SQL queries in VB 6.0

Posted 30 October 2009 - 04:20 AM

View Postvb5prgrmr, on 29 Oct, 2009 - 06:36 PM, said:

No need for brackets around table name unless table name has a space in its name. If the pound symbol (#) does not work, try single ticks ('). (Long shot...)...



Good Luck



Thank you for your suggesmtion.
But, it is still NOT Working
Was This Post Helpful? 0
  • +
  • -

#6 vb5prgrmr  Icon User is offline

  • D.I.C Lover

Reputation: 109
  • View blog
  • Posts: 1,016
  • Joined: 21-March 09

Re: SQL queries in VB 6.0

Posted 30 October 2009 - 08:47 AM

Like I said (Long shot...)...
Was This Post Helpful? 0
  • +
  • -

#7 bytelogik  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 212
  • Joined: 06-October 09

Re: SQL queries in VB 6.0

Posted 30 October 2009 - 10:12 AM

try this:

Set DBRecord ="Select * from " & tblname & " where (Name1= 'ALFA') Or (name1= 'BHTA' AND date1 = #" & stDate & "#)"
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1