Public Sub CnWithDSN
Dim Connection
Dim Recordset
Dim SQL
declare the SQL statement that will query the database
SQL = "SELECT * FROM ARTICULOS"
create an instance of the ADO connection and recordset objects
Set Connection = CreateObject("ADODB.Connection")
Set Recordset = CreateObject("ADODB.Recordset")
open the connection to the database
Connection.Open "DSN=mySql"
Open the recordset object executing the SQL statement and return records
Recordset.Open SQL,Connection
first of all determine whether there are any records
If Recordset.EOF Then
MsgBox "No records returned."
Else
MsgBox "Records found"
End If
close the connection and recordset objects freeing up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=Nothing
End Sub
On Tue, Jul 30, 2013 at 5:08 AM, <[email protected]> wrote:
> Hello, I am kinda new to VBScript, but have used C# to pull data from a
> SQL Server db using DataTables and Reader, etc, however I am at a loss as
> to how to accomplish this in VBScript. I have a variable, which the user
> specifies, that I wish to use as a parameter in a SQL string, much like the
> following: "SELECT x FROM y WHERE x = '@param'" The result will then be
> stored in a string variable and I wiill do what I have to do with it. Can
> someone help me set this up. Sorry if it's a silly question, I'm just very
> new to VB. BTW, this is for a VB Script :/ Thanks!
>
> --
> --
> You received this message because you are subscribed to the Google
> "QTP - HP Quick Test Professional - Automated Software Testing"
> group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/MercuryQTP?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "QTP - HP Quick Test Professional - Automated Software Testing" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en
---
You received this message because you are subscribed to the Google Groups "QTP
- HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.