1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

asp - mssql 2005 connection string issue. please help. very wierd problem!

Discussion in 'C#' started by Slinni, Mar 28, 2009.

  1. #1
    I have been using ASP for a long time now, never had this come up before.

    We are using godaddy hosting with an MSSQL 2005 db. My connection string that I use locally on our servers and on many other company servers works great, but on godaddy doesnt work worth a darn.

    so after about 5 hours on tech support., they give me this code to work with.

    Wierd thing about it is, if I send the data through the form as far as db,pw,server info etc. it works fine, but I cant hard code it. I need to be able to have this working hard coded since it is included in a file on each page of the site..

    What am I not doing? Is the form sending something different than if I were to just code in the details?? Im totally lost.

    any ideas??? please help.

    Thanks in advance!

    here is the code they provided me to work with. ============

    
    
    <h3>ASP - MSSQL Connection Test Script</h3>
    Enter the database information below to test connecting to that database from this hosting account.<br /><br />
    
    <FORM METHOD="POST" ACTION="mssql.asp">
    <table>
    <tr><td>User:</td><td><INPUT TYPE="text" id="UID" name="UID" /></td></tr>
    <tr><td>Pass:</td><td><INPUT TYPE="text" id="PWD" name="PWD" /></td></tr>
    <tr><td>DB:</td><td><INPUT TYPE="text" id="DB" name="DB" /></td></tr>
    <tr><td>Server:</td><td><INPUT TYPE="text" id="SERV" name="SERV" /></td></tr>
    <tr><td></td><td><INPUT TYPE="submit" id="submit" name="submit"></td></tr>
    </table>
    </FORM>
    
    <%
    if Request.Form("submit") <> "" Then
    
    dim Conn
    dim DSN
    dim UID
    dim PWD
    dim DB
    dim SERV
    
    UID=Request.Form("UID")
    PWD=Request.Form("PWD")
    DB=Request.Form("DB")
    SERV=Request.Form("SERV")
    
    	Set Conn = Server.CreateObject("ADODB.Connection")
    	DSN="DRIVER={SQL Server};SERVER="&SERV&"; UID="&UID&"; PWD="&PWD&"; DATABASE="&DB&";"
    	Conn.open DSN
    	Response.Write("Connection Successful.")
    	
    end if
    %>
    
    
    Code (markup):

    here is what I did to use it hard coded. ======================

    
    
    
    <%
    dim Conn
    dim DSN
    dim UID
    dim PWD
    dim DB
    dim SERV
    
    UID="theUSERNAME"
    PWD="thePW"
    DB="theDBname"
    SERV="asdf.db.asdfasdfetc.."
    
    	Set Conn = Server.CreateObject("ADODB.Connection")
    	DSN="DRIVER={SQL Server};SERVER="&SERV&"; UID="&UID&"; PWD="&PWD&"; DATABASE="&DB&";"
    	Conn.open DSN
    	Response.Write("Connection Successful.")
    	
    end if
    %>
    
    
    Code (markup):

    as well as tried this.. ==================================

    
    
    <%
    dim Conn
    dim DSN
    dim UID
    dim PWD
    dim DB
    dim SERV
    
    
    	Set Conn = Server.CreateObject("ADODB.Connection")
    	DSN="DRIVER={SQL Server};SERVER=asdf.db.asdfasdfetc..; UID=theUSERNAME; PWD=thePW; DATABASE=theDBname;"
    	Conn.open DSN
    	Response.Write("Connection Successful.")
    	
    end if
    %>
    
    
    
    
    Code (markup):
     
    Slinni, Mar 28, 2009 IP
  2. MayurGondaliya

    MayurGondaliya Well-Known Member

    Messages:
    1,233
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    170
    #2
    What error message do you receive? And are you sure that connection is not timing out?
     
    MayurGondaliya, Apr 5, 2009 IP
  3. Jhar

    Jhar Peon

    Messages:
    318
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What event do you have triggering the hardcoded version? Also if that is your exact code you have an "end if" statement with no "if" statement.

    Have you tried a standard connectionstring in your web.config with the form of:

    <connectionStrings>

    <add name=”Personal” connectionString=” Server=whsql-v04.prod.mesa1.....; Database=theDB; User ID=user_id; Password=password; Trusted_Connection=False” providerName=”System.Data.SqlClient” /> <remove name=”LocalSqlServer”/> <add name=”LocalSqlServer” connectionString=” Server=whsql-v04.prod.mesa1......; Database=theDB; User ID=user_id; Password=password; Trusted_Connection=False” providerName=”System.Data.SqlClient” />

    </connectionStrings>
     
    Jhar, Apr 10, 2009 IP