Hello all,
I am trying to connect to sqlserver on godaddy but facing so much trouble with the connection strings. I wanted to use C# but wasnt successfully in making a connection.
when i simply copy-pasted their vb-script connection strings sample.. it worked.
I tried to modify vb to c# accordingly with no success.
If anybody knows how to connect to godaddy sqlserver in C# please let me know..
Thankyou all in advance.

Their vbscript connection sample is as follows.. any little light on this might solve my problem..


'Sample Database Connection Syntax for ASP and SQL Server.

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"
fieldname = "your_field"
tablename = "your_table"

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

qry = "SELECT * FROM " & tablename

Set oRS = oConn.Execute(qry)

Do until oRs.EOF
   Response.Write ucase(fieldname) & ": " & oRs.Fields(fieldname)

Set oRs = nothing
Set oConn = nothing


To connect to SQL Server by C# application you need to use ADO.NET libraries

To connect to SQL Server by C# application you need to use ADO.NET libraries

like importing and using System.Data and System.Data.SqlClient??

Made use of them too..

So, tell me your problem, what you did and what you got?

U See ADO.net database connection. I hope will get solve your problem.

c# connection

SqlConnection cnn ;
string connetionString = "Data Source=ServerName;
Initial Catalog=DatabaseName;
User ID=UserName;
Password=Password" ;

cnn = new SqlConnection(connetionString);
                MessageBox.Show ("Connection Open ! ");
            catch (Exception ex)
                MessageBox.Show("Can not open connection ! ");

full source code here


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.