Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Asp Connection Strings Query 1

Status
Not open for further replies.

Manxman55

IS-IT--Management
Aug 16, 2005
5
GB
I am a novice at using database websites. I need to connect to a MySQL database on a remote server using ASP......

I have been given the following by tech support at my ISP (Fasthosts).....

"DRIVER={MySQL ODBC 3.51 Driver};SERVER=data.domain.com;PORT=3306;DATABASE=myDatabase; USER=myUsername;PASSWORD=myPassword;OPTION=3;"

My questions are

Is "DRIVER" a Memory Variable, and if so,

Does "DRIVER" gain a value (True or False) if the connection is successful or not (respectively)?

Can anybody let me have a more complete ASP script which will let me know if the connection has been sucessful or not.
 
I don't know what a "Memory Variable" is, but I doubt "DRIVER" is one. "DRIVER" is part of a text string that you are going to pass a function in order to establish a DSNless connection to the database.

Something like:

Set Connection = Server.CreateObject("ADODB.Connection")
Connection.open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=data.domain.com;PORT=3306;DATABASE=myDatabase; USER=myUsername;PASSWORD=myPassword;OPTION=3;"

The "open" method of the "ADODB.Connection" object should return one type of value on success, another on failure. Check your language documentation for details.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Excellent !! Thanks very much for that one.

Next silly question,

Can I use an IP address for "SERVER" instead of "data.domain.com"?
 
OK Guys,

I got the database open with the following code (which all works perfectly)....

// Build the sql statement
m_strSQL = "select * from <datatable> where Remote_IP Like '%" & Request.ServerVariables("REMOTE_ADDR") & "%';"
// Create the MySQL Connection.
set MySQLConn = server.createobject("adodb.connection")
// Open the Database
MySQLConn.open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=<IP Address>;DATABASE=(Database Name>;USER=<User Name>;PASSWORD=<Password>;OPTION=3;"
// Open recordset
Set objRS = MySQLConn.Execute(m_strSQL)
//
If objRS.EOF Then Response.Redirect("ID_Survey.asp")
//
%>

Silly question is, having directed the browser to another page, (or stayed on this one depending on the "objRS.EOF" result) how do I close the Database and Connection?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top