Connection SQL server

S

Souris

I wnated to write a connection to my SQL server, but I got fail.
The folowing is my code.

Can you please tell me where I am wrong?

<%
set conn = Server.CreateObject("ADODB.Connection")
set cmd = Server.CreateObject("ADODB.Command")

sConnString = "Provider=SQLOLEDB.1;User ID=Test1;password=Test1;Initial
Catalog=MyDataBase;Data Source = MyServer"


Conn.Open sConnString
Set cmd.ActiveConnection = Conn
cmd.CommandText = "SELECT * FROM Client"
cmd.CommandType = adCmdText

Set rs = cmd.execute

Do While Not rs.EOF
For iCtr = 0 To rs.fields.Count - 1
response.write rs.fields(iCtr).Name & ": "
response.write rs.fields(iCtr).Value & "<BR>"
Next
rs.MoveNext
Loop
Set rs = Nothing
Set cmd = Nothing
Conn.Close
set conn = nothing

Your information is great appreciated,


I got error message on
"Set cmd.ActiveConnection = Conn"


Error message is following:

Error Type:

ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another
 
J

john smith

Souris said:
I wnated to write a connection to my SQL server, but I got fail.
The folowing is my code.

Can you please tell me where I am wrong?

<%
set conn = Server.CreateObject("ADODB.Connection")
set cmd = Server.CreateObject("ADODB.Command")

sConnString = "Provider=SQLOLEDB.1;User ID=Test1;password=Test1;Initial
Catalog=MyDataBase;Data Source = MyServer"


Conn.Open sConnString
Set cmd.ActiveConnection = Conn
cmd.CommandText = "SELECT * FROM Client"
cmd.CommandType = adCmdText

Set rs = cmd.execute

Do While Not rs.EOF
For iCtr = 0 To rs.fields.Count - 1
response.write rs.fields(iCtr).Name & ": "
response.write rs.fields(iCtr).Value & "<BR>"
Next
rs.MoveNext
Loop
Set rs = Nothing
Set cmd = Nothing
Conn.Close
set conn = nothing

Your information is great appreciated,


I got error message on
"Set cmd.ActiveConnection = Conn"


Error message is following:

Error Type:

ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another
You might get more relevant replies by posting in the correct newsgroup.
This is not web services related, nor asp.net related, or even .net
related in any way...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top