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
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