Help Running SQL thru VB

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2007
Posts: 2
Reputation: bakedsushi is an unknown quantity at this point 
Solved Threads: 0
bakedsushi bakedsushi is offline Offline
Newbie Poster

Help Running SQL thru VB

 
0
  #1
Sep 24th, 2007
I am making a simple payroll program that keeps track of my hours, jobs, descriptions, etc. It also keeps track of the checks I've gotten. I have three main tables: Hours consisting of date, time started, ended, total hours, customer, job, description, Payperiod number, I know this one could be broken down more but that's not what I'm after right now. The other two are two are Checks and PayPeriod each with a matching index for joining. That part works fine. I'm using Flexgrids for my output. I would like to use a combo box so I can look at individual pay periods(1,2,3, Pay Period Index). After alot of frustration, I finally got what I thought would work but it now tells me Microsoft Jet Engine can't find table check spelling or existence done both don't know why anymore. Here's part of whats written the reason I didn't use * was because I didn't want to show period or index columns

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. If cboViews.Text = "By Period" Then
  2. If cboPeriod.Text <> "" Then
  3. QueryOne = " Select Hours.date,Hours.[time started],hours.[time ended],hours.[hours _ worked],hours.customer,hours.description From Hours where hours.period = '" & _ cboPeriod.Text & "' Order by hours.date desc, hours.[time started] asc"
  4. datHours.RecordSource = Chr(34) & QueryOne & Chr(34)
  5. datHours.Refresh
  6. flxHours.Refresh
  7. Else
  8. ErrMess = "Please select a period"
  9. MsgBox ErrMess
  10. End If
  11. End If
Please Help with as little laughter as possible I did not go to school for this nor am I it is for broadening my horizons and learning I've been reading books and trying to figure it out but as of yet I have not.

Thanks,

Bakedsushi
Last edited by bakedsushi; Sep 24th, 2007 at 11:11 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 193
Reputation: plusplus is an unknown quantity at this point 
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

Re: Help Running SQL thru VB

 
0
  #2
Sep 25th, 2007
First of all you should not have any spaces in your column headings in the database, change
time started to time_started in your database etc

Second, in your query you are only selecting from hours table so you don't need to say
select hours.date
but only select date etc from hours
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 538
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: Help Running SQL thru VB

 
0
  #3
Sep 25th, 2007
there is simple syntax error in ur code. use the following :-
QueryOne = "Select date,time_started,time_ ended,hours_worked,customer,description From Hours where period='" & _ cboPeriod.Text & "' Order by date desc, time _started asc"
datHours.RecordSource = trim(QueryOne)

**replace all of ur fields that have
space with underscore.**
Last edited by choudhuryshouvi; Sep 25th, 2007 at 1:52 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 2
Reputation: bakedsushi is an unknown quantity at this point 
Solved Threads: 0
bakedsushi bakedsushi is offline Offline
Newbie Poster

Re: Help Running SQL thru VB

 
0
  #4
Sep 25th, 2007
Okay, I tried that now I get another error too few parameters expected 3
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 538
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: Help Running SQL thru VB

 
0
  #5
Sep 26th, 2007
Originally Posted by bakedsushi View Post
Okay, I tried that now I get another error too few parameters expected 3
that because of you are calling more fields in query rather than what is restricted.
use '* from' in your query to fetch all fields from the table. then display value of only those fields which you are wanting.

Regards
Shouvik
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1137 | Replies: 4
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC