From: mcolson on
I am using the following code to perform a SQL query and return a
recordset I am getting the error "Arguments are of the wrong type,
are out of acceptable range, or are in conflict with one another"
This error occurs when I open the record set. What am I doing wrong?

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=ChartMES;"
objRecordset.CursorLocation = adUseClient


strQuery = "Use ChartMES " _
& "SELECT EmployeeID " _
& "FROM dbo.viewEmployeeTraining " _
& "WHERE TrainingName = 'Inner / Outer Mass Spec Training' " _
& "ORDER BY EmployeeID"

' Echo the query to the console to verify.
Wscript.Echo strQuery

'objRecordset.Source = strQuery
objRecordset.Open strQuery, objConnection, adOpenStatic,
adLockOpstimistic
If objRecordset.EOF Then
Wscript.Echo "Record cannot be found."
Else
Wscript.Echo "Record found."
End If
objRecordset.Close
objRecordset.Close
From: Tom Lavedas on
On Mar 9, 11:20 am, mcolson <mcolson1...(a)gmail.com> wrote:
> I am using the following code to perform a SQL query and return a
> recordset  I am getting the error "Arguments are of the wrong type,
> are out of acceptable range, or are in conflict with one another"
> This error occurs when I open the record set.  What am I doing wrong?
>
> Const adOpenStatic = 3
> Const adLockOptimistic = 3
> Const adUseClient = 3
> Set objConnection = CreateObject("ADODB.Connection")
> Set objRecordset = CreateObject("ADODB.Recordset")
> objConnection.Open "DSN=ChartMES;"
> objRecordset.CursorLocation = adUseClient
>
> strQuery = "Use ChartMES " _
>         & "SELECT EmployeeID " _
>     & "FROM dbo.viewEmployeeTraining " _
>     & "WHERE TrainingName = 'Inner / Outer Mass Spec Training' " _
>     & "ORDER BY EmployeeID"
>
> ' Echo the query to the console to verify.
> Wscript.Echo strQuery
>
> 'objRecordset.Source = strQuery
> objRecordset.Open strQuery, objConnection, adOpenStatic,
> adLockOpstimistic
> If objRecordset.EOF Then
>     Wscript.Echo "Record cannot be found."
> Else
>     Wscript.Echo "Record found."
> End If
> objRecordset.Close
> objRecordset.Close

Is there a typo in this line ?...

objRecordset.Open strQuery, objConnection, adOpenStatic,
adLockOpstimistic

I think you intended the last constant to be "adLockOptimistic" (no S
after the P).
_____________________
Tom Lavedas
From: mcolson on
On Mar 9, 10:53 am, Tom Lavedas <tglba...(a)verizon.net> wrote:
> On Mar 9, 11:20 am, mcolson <mcolson1...(a)gmail.com> wrote:
>
>
>
> > I am using the following code to perform a SQL query and return a
> > recordset  I am getting the error "Arguments are of the wrong type,
> > are out of acceptable range, or are in conflict with one another"
> > This error occurs when I open the record set.  What am I doing wrong?
>
> > Const adOpenStatic = 3
> > Const adLockOptimistic = 3
> > Const adUseClient = 3
> > Set objConnection = CreateObject("ADODB.Connection")
> > Set objRecordset = CreateObject("ADODB.Recordset")
> > objConnection.Open "DSN=ChartMES;"
> > objRecordset.CursorLocation = adUseClient
>
> > strQuery = "Use ChartMES " _
> >         & "SELECT EmployeeID " _
> >     & "FROM dbo.viewEmployeeTraining " _
> >     & "WHERE TrainingName = 'Inner / Outer Mass Spec Training' " _
> >     & "ORDER BY EmployeeID"
>
> > ' Echo the query to the console to verify.
> > Wscript.Echo strQuery
>
> > 'objRecordset.Source = strQuery
> > objRecordset.Open strQuery, objConnection, adOpenStatic,
> > adLockOpstimistic
> > If objRecordset.EOF Then
> >     Wscript.Echo "Record cannot be found."
> > Else
> >     Wscript.Echo "Record found."
> > End If
> > objRecordset.Close
> > objRecordset.Close
>
> Is there a typo in this line ?...
>
> objRecordset.Open strQuery, objConnection, adOpenStatic,
> adLockOpstimistic
>
> I think you intended the last constant to be "adLockOptimistic" (no S
> after the P).
> _____________________
> Tom Lavedas

ahh jeez. Thanks