sql server and ASP

  • I'm trying to connect SQl database remotely via IP address with ASP files. The connection string that i wrote is:

    <%

    Dim conn,sqlstmt,sFname,sLanme,sPhone,sMemid

    sMemid = request.Form("mem_id")

    set conn=Server.CreateObject("ADODB.Connection")

     

     conn.connectionstring = "server=xxx.xxx.x.x;uid=sa;initial catalog=MemberProfile;"

    sqlstmt = "Select * from tmp_member where memberid= " & sMemid

    set rsSelect= server.CreateObject("ADODB.recordset")

     rsSelect.open sqlstmt, conn

        sFname=rsSelect.fields("fname")

        sLname=rsSelect.fields("lname")

     sPhone=rsSelect.fields("phone")

        sMembertype=rsSelect.fields("membertype")

        sTitle=rsSelect.fields("title")

     sDesignation=rsSelect.fields("designation")

        sSection=rsSelect.fields("section1")

     sOrganization=rsSelect.fields("orgname")

          conn.execute(sqlstmt)

    rsSelect.close

    set rsSelect=nothing

          conn.close

          set conn=nothing

          set sqlstmt=nothing

    %>

    xxx.xxx.x.x is the IP address of the server that sql database and serrver stored.When i run this ASP file, it doesn't work and how can i fix it? Please suggest me.

     

  • Is your sa password null or have you intentionally left it out of the connection string?

    I won't rant about connecting using 'sa', especially from and ASP page, but...

    Ian Dundas
    Senior IT Analyst - Database
    Manitoba Public Insurance Corp.

  • Yep, you definitely need a password in there unless as Ian says you've not got one (slap on wrist).  Remember, these things have a nasty habit of making it into production, and you don't want to change your code after it's been tested.

    Alternatively, you could use NT security  - have a look at http://www.connectionstrings.com, it's a useful site that I point developers to, always handy when setting up a new one. Recommend that you print out the ones you're likely to use frequently and put them in a folder, can never remember the exact syntax.


    Jon

  • What was the error message? Sure, there should be a password for a login, but it could be also many other reasons for the script not to run.

    Uncheck "Show Friendly HTTP Error messages" on the Advanced tab of yor Internet Explorer properties

    Yelena

    Regards,Yelena Varsha

  • I don't think you want this line in there:

    conn.execute(sqlstmt)

    If it isn't actually causing an error, it's not doing anything constructive, that's for sure.

  • This line is bad, too:

    set sqlstmt=nothing

    sqlstmt isn't an object, so you don't "set" it.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply