Connection SQL server

Discussion in 'ASP .Net Web Services' started by Souris, Jan 14, 2006.

  1. Souris

    Souris Guest

    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
    Souris, Jan 14, 2006
    #1
    1. Advertising

  2. Souris

    john smith Guest

    Souris wrote:
    > 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...
    john smith, Jan 14, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UmV6YQ==?=
    Replies:
    3
    Views:
    17,894
    Carlos Barini
    Jun 7, 2004
  2. Daves
    Replies:
    1
    Views:
    364
  3. Joey
    Replies:
    3
    Views:
    4,422
  4. Geoff
    Replies:
    3
    Views:
    432
    Patrick.O.Ige
    Jan 16, 2006
  5. farseer

    SQL Server 2005 + SQL Server Express

    farseer, Aug 7, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    337
    farseer
    Aug 8, 2006
Loading...

Share This Page