VB Variables in SQL Select Statement?!?! 
Author Message
 VB Variables in SQL Select Statement?!?!

I am trying to setup a small dB on our SQL 7 Server and configure a front
end in VB6 Enterprise. I am new to programming for Databases... I would like
an input box to prompt the user for the ID of the employee record they are
looking for, this is also the primary key to the database. I can setup this
part, assign a value to the variable, what i cannot figure out is how to ask
SQL via VB to

select * from main where empnum = [VB Variable]

What this needs to do is display the desired record for modification... Any
one know how to do this??? Please help!

Brian




Sat, 01 Dec 2001 03:00:00 GMT  
 VB Variables in SQL Select Statement?!?!
Brian,

Like this:

"select * from main where empnum =" & [VB Variable]

--
Regards

VB-Joker
Carsten Thomsen/MCSE

PLEASE post ALL replies to the newsgroup(s) so we can all benefit from the
discussion!


Quote:
> I am trying to setup a small dB on our SQL 7 Server and configure a front
> end in VB6 Enterprise. I am new to programming for Databases... I would
like
> an input box to prompt the user for the ID of the employee record they are
> looking for, this is also the primary key to the database. I can setup
this
> part, assign a value to the variable, what i cannot figure out is how to
ask
> SQL via VB to

> select * from main where empnum = [VB Variable]

> What this needs to do is display the desired record for modification...
Any
> one know how to do this??? Please help!

> Brian





Sat, 01 Dec 2001 03:00:00 GMT  
 VB Variables in SQL Select Statement?!?!
Stupid Question #1
How do i have the form open with only the data from the select statement?


Quote:
> Brian,

> Like this:

> "select * from main where empnum =" & [VB Variable]

> --
> Regards

> VB-Joker
> Carsten Thomsen/MCSE

> PLEASE post ALL replies to the newsgroup(s) so we can all benefit from the
> discussion!


> > I am trying to setup a small dB on our SQL 7 Server and configure a
front
> > end in VB6 Enterprise. I am new to programming for Databases... I would
> like
> > an input box to prompt the user for the ID of the employee record they
are
> > looking for, this is also the primary key to the database. I can setup
> this
> > part, assign a value to the variable, what i cannot figure out is how to
> ask
> > SQL via VB to

> > select * from main where empnum = [VB Variable]

> > What this needs to do is display the desired record for modification...
> Any
> > one know how to do this??? Please help!

> > Brian





Sat, 01 Dec 2001 03:00:00 GMT  
 VB Variables in SQL Select Statement?!?!
I'm not certain from your message whether you are using data bound controls
or not... if you are then you would set the recordsource property of your
data control tool to whatever you need it to be and the refresh the data
control.

If you are using database and recordset variables then you will have to set
each field manually like....

Dim Rs as recordset

set rs = db.openrecordset(SQL)

txtName = rs.Fields("FirstName")
etc...
etc..

Hope this helps

Nick August



Quote:
> Stupid Question #1
> How do i have the form open with only the data from the select statement?



> > Brian,

> > Like this:

> > "select * from main where empnum =" & [VB Variable]

> > --
> > Regards

> > VB-Joker
> > Carsten Thomsen/MCSE

> > PLEASE post ALL replies to the newsgroup(s) so we can all benefit from
the
> > discussion!


> > > I am trying to setup a small dB on our SQL 7 Server and configure a
> front
> > > end in VB6 Enterprise. I am new to programming for Databases... I
would
> > like
> > > an input box to prompt the user for the ID of the employee record they
> are
> > > looking for, this is also the primary key to the database. I can setup
> > this
> > > part, assign a value to the variable, what i cannot figure out is how
to
> > ask
> > > SQL via VB to

> > > select * from main where empnum = [VB Variable]

> > > What this needs to do is display the desired record for
modification...
> > Any
> > > one know how to do this??? Please help!

> > > Brian





Tue, 04 Dec 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. WHERE clause containing a variable in a SQL SELECT statement

2. Referring to program variables in an ASP SQL select statement

3. Help! VB and Access SQL select statement

4. Using VB 5.0 Variables in an SQL Statement

5. VB 5, variables inside SQL statements

6. Using VB 5.0 Variables in an SQL Statement

7. Using VB 5.0 Variables in an SQL Statement

8. Using VB 5.0 Variables in an SQL Statement

9. SQL query: from SELECT statement to stored procedure with dynamic PL/SQL

10. String variable in SELECT statement

11. A (simple) SELECT statement using variables

12. A (simple) SELECT statement using variables

 

 
Powered by phpBB® Forum Software