Problem with connection string

I'm trying to use a driver connection string to open the connection to my database.
The first time I load the page I get this error:
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
I am getting this on the .activeconnection line.

I don't see anything wrong with my code, so I go back to my page and hit F5, and the page loads properly.

What am I doing wrong?
Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
MM_donorSelect_app1 = "DRIVER={SQL Server};Server=8888;Database=8888;Uid88888;Pwd=888888;"
MM_CMS_STRING = stringUse

Recordset1_cmd.ActiveConnection = MM_CMS_STRING

Recordset1_cmd.CommandText = "SELECT * FROM eventsQ" 
Recordset1_cmd.Prepared = true

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0

Open in new window

rivkamakAsked:
Who is Participating?
 
EyalConnect With a Mentor Commented:
try this
<%
  openConnection = false
MM_donorSelect_app1 = "DRIVER={SQL Server};Server=***.***.***.***;Database=OorahCMS;Uid=CMS-Oorah;Pwd=800spring;"
MM_donorSelect_app2 = "DRIVER={SQL Server};Server=***.***.**.**;Database=OorahCMS;Uid=CMS-Oorah;Pwd=800spring;"
MM_donorSelect_app3 = "DRIVER={SQL Server};Server=**.**.***.***;Database=OorahCMS;Uid=CMS-Oorah;Pwd=800spring;"

Dim ADOErrors, ADOError

Set myConn = Server.CreateObject("ADODB.Connection")
On Error Resume Next
myConn.open MM_donorSelect_app1
Set ADOErrors = myConn.Errors
On Error GoTo 0

If ADOErrors.Count = 0 then
	If myConn.State = 1 then 
		openConnection = true
	End If
End If

'try connection 2
if openConnection = false then
	Dim ADOErrors2, ADOError2

	On Error Resume Next
	myConn.open MM_donorSelect_app2
	Set ADOErrors = myConn.Errors
	On Error GoTo 0

	If ADOErrors.Count = 0 then
		If myConn.State = 1 then 
			openConnection = true
		End If
	End If

end if ' check connection
'
if openConnection = false then

	On Error Resume Next
	myConn.open MM_donorSelect_app3
	Set ADOErrors = myConn.Errors
	On Error GoTo 0

	If ADOErrors.Count = 0 then
		If myConn.State = 1 then 
			openConnection = true
		End If
	End If
end if ' open connection

MM_CMS_STRING = stringUse

Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")

Recordset1_cmd.ActiveConnection = myConn
Recordset1_cmd.CommandText = "SELECT * FROM eventsQ" 
Recordset1_cmd.Prepared = true

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>

Open in new window

0
 
raysonleeCommented:
"=" sign missing after Uid?
0
 
rivkamakAuthor Commented:
no, sorry, it just got erased when I took out the real number
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
raysonleeCommented:
Use Provider=MSDASQL to replace DRIVER={SQL Server} or simply remove it as it is the default.
0
 
EyalCommented:
you will find your answer here
http://www.connectionstrings.com/
0
 
sebastienboCommented:
dim strSQL
set Global_DBConnection=Server.CreateObject("ADODB.Connection")
DSN="Driver={SQL Server};Server=000.000.000.000;Database=DATABASENAME;UID=USERNAME;PWD=PASSWORD"
Global_DBConnection.Open(DSN)
0
 
rivkamakAuthor Commented:
You are all missing the question.
I have that string correct in my script.
When you load the page the first time, you get this error:

ADODB.Command error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

But if you hit refresh the page loads properly.

Why the first time around am I hitting an error, yet, my code does work properly the second time?
0
 
rivkamakAuthor Commented:
sebastienbo-
based on your answer of changing the script to .open,

how do I continue making a recordset?


Recordset1_cmd.ActiveConnection = MM_CMS_STRING
Recordset1_cmd.CommandText = "SELECT * FROM eventsQ"
Recordset1_cmd.Prepared = true
Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
0
 
EyalCommented:
not sure it will solve something but...

Set Recordset1 = Recordset1_cmd.Execute()
0
 
rivkamakAuthor Commented:
That last example won't work for me. I'm using straight ASP not ASP.NET
What else might solve this error message?

ADODB.Command error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
0
 
EyalCommented:
how do you know it fails in this statement and not other?
put response.end before the execute
press F5
if you don't get an error move it after the execute and press again F5
do you get the error now?
0
 
raysonleeCommented:
0
 
raysonleeCommented:
Details about the error code: http://support.microsoft.com/kb/254517/en-us
0
 
rivkamakAuthor Commented:
This is the entire list of code.

this line is the line of error i'm getting:
Recordset1_cmd.ActiveConnection = MM_CMS_STRING

<%
  openConnection = false
MM_donorSelect_app1 = "DRIVER={SQL Server};Server=***.***.***.***;Database=OorahCMS;Uid=CMS-Oorah;Pwd=800spring;"
MM_donorSelect_app2 = "DRIVER={SQL Server};Server=***.***.**.**;Database=OorahCMS;Uid=CMS-Oorah;Pwd=800spring;"
MM_donorSelect_app3 = "DRIVER={SQL Server};Server=**.**.***.***;Database=OorahCMS;Uid=CMS-Oorah;Pwd=800spring;"

Dim ADOErrors, ADOError

Set myConn = Server.CreateObject("ADODB.Connection")
On Error Resume Next
myConn.open MM_donorSelect_app1
Set ADOErrors = myConn.Errors
On Error GoTo 0

If ADOErrors.Count = 0 then
	If myConn.State = 1 then 

		stringUse = MM_donorSelect_app1
		openConnection = true

	End If
End If

'try connection 2
if openConnection = false then
	Dim ADOErrors2, ADOError2

Set myConn2 = Server.CreateObject("ADODB.Connection")
On Error Resume Next
myConn2.open MM_donorSelect_app2
Set ADOErrors2 = myConn2.Errors
On Error GoTo 0

If ADOErrors2.Count = 0 then
	If myConn2.State = 1 then 

		stringUse = MM_donorSelect_app2
		openConnection = true
	End If

End If


end if ' check connection
'
if openConnection = false then
	Dim ADOErrors3, ADOError3

Set myConn3 = Server.CreateObject("ADODB.Connection")
On Error Resume Next
myConn3.open MM_donorSelect_app3
Set ADOErrors3 = myConn3.Errors
On Error GoTo 0

If ADOErrors3.Count = 0 then
	If myConn3.State = 1 then 
		stringUse = MM_donorSelect_app3
		openConnection = true
	End If
End If
end if ' open connection

MM_CMS_STRING = stringUse

%>

<%

Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")

Recordset1_cmd.ActiveConnection = MM_CMS_STRING
Recordset1_cmd.CommandText = "SELECT * FROM eventsQ" 
Recordset1_cmd.Prepared = true

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.