Link to home
Start Free TrialLog in
Avatar of johnywhite
johnywhite

asked on

Sql Connection to Godaddy MSSQL Server

I have a GoDaddy web-hosting account.  They allow me to create a SQL Server 200 Database.  They have given me code for asp, however I am using asp.net w/vb.net codebehind.  The code that they have given me to connect to their database in asp is:
Dim oConn, oRs
Dim qry, connectstr
Dim db_name, db_username, db_userpassword
Dim db_server

db_server = "whsql01.mesa1.secureserver.net"
db_name = "your_dbname"
db_username = "your_dbusername"
db_userpassword = "your_dbpassword"

connectstr = "Driver={SQL Server};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr


My code in VB.NET is this:
dim dbname as string = "my database name"
dim db_username as string = "my user name"
dim dbpassword as string = "my password"
dim connec As New OleDbConnection("Provider=SQLOLEDB;Data Source=whsql01.mesa1.secureserver.net;Initial Catalog=" & dbname & ";User Id=" & db_username & ";Password=" & dbpassword)
connec.open()

I have also tried using OdbcConnection with the exact same string as their connectstr.  With both ways I get the error SQL Server not found or access denied.  I was wondering if anyone has a solution for this or experienced the same thing with GoDaddy?  Is there something different with the way asp connects as to the way asp.net does?  Any help would be appreciated.
ASKER CERTIFIED SOLUTION
Avatar of abanup
abanup

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of johnywhite
johnywhite

ASKER

I tried both of those and still the same error. "SQL Server does not exist or access denied."
Hi
try this:

dim connec As New SqlConnection("Integrated Security=SSPI; Persist Security Info=False; DataSource=whsql01.mesa1.secureserver.net; InitialCatalog=" & dbname & "; User Id=" & db_username & "; Password=" & dbpassword)

note: try to give space after semicoln (but i don't think it cause any problem);
Same error. "SQL Server does not exist or access denied."

P.S.
Data Source and Initial Catalog require spaces.  Just for if anyone else ever uses this in the future.
Which service plan you are using ? https://www.godaddy.com/gdshop/hosting/landing.asp?se=%2B&rhl=nv%5Fweb%5F%2Fdefault%5Fhost , it shows Economy Plan does NOT support ASP.Net.
-Baan
I am using the Delux with Asp.  My web site is also written in .NET and it works just fine.
I suggest you talk to them about the exact SQL Server name. Because your connection string looks just fine. There is absolutely no problem.
-Baan
Avatar of Éric Moreau
Your SQL server does not allow

-Open Enterprise Manager
-Right-click your server
-Click properties
-Open the Security tab
-Set Authentication to "SQL Server and Windows"
-Let the service restart
It turns out that they don't allow connections to a database through .NET only through asp, even though they offer .NET as an option.
Thanks for all of the help I appreciate it.