RESOLVED First Time I use MYSQL
Hello all and thanks for taking the time
If some one can direct me to some docs that will show me
1. How to connect to mysql db with a webpage
2. How to connect to mysql db with vb6
A little background i have been playing with access db for a while now and im quite comfortable with them. But if i want to put my db on a web server unless the webserver supports MSaccess i have to use mysql (As far as i have found out through the search option on this site)
I have tried using the MySQL manual and certain online tutorials through google but they just seem to show you how to use mysql through the console.
I m ussually pretty good at this thing but for some reason i m soooo lost
if anyone can please help it will muchly appreciated.
Thanks
ps. Hope this makes sense
Re: First Time I use MYSQL
what scripting language will u be using? and what web server?
VisualAd has a very nice tutorial on connecting everything when u are using PHP, Apache, MySQL.
as for connecting to vb6.. you need an odbc driver of MySQL for that. :)
Re: First Time I use MYSQL
Re: First Time I use MYSQL
Here is what I use to connect to MySql:
VB Code:
Option Explicit
Private strDataBaseName As String
Private strDBCursorType As String
Private strDBLockType As String
Private strDBOptions As String
Private strSQL as String
Private rs As ADODB.Recordset
Private cn As ADODB.Connection
Private Sub Command1_Click()
On Error GoTo Command1_Click_Error
Dim b as Long
strDBCursorType = adOpenDynamic 'CursorType
strDBLockType = adLockOptimistic 'LockType
strDBOptions = adCmdText 'Options
Set cn = New ADODB.Connection
Me.MousePointer = 11
cn.Open ConnectString()
With cn
.CommandTimeout = 0
.CursorLocation = adUseClient
End With
Set rs = New ADODB.Recordset 'Creates record set
strSQL = "<Your SQL Here>"
rs.Open strSQL, cn, strDBCursorType, strDBLockType, strDBOptions
if rs.Eof then
Goto ExitSub
else
For b = 1 To rs.RecordCount
'<do whatever you need to do with the data here>
Next b
end if
ExitSub:
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
On Error GoTo 0
Exit Sub
Command1_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") & _
in procedure Command1_Click of Form " & Me.Name
End Sub
Private Function ConnectString() As String
Dim strServerName as String
Dim strDatabaseName as string
Dim strUserName as string
Dim strPassword as string
'Change to IP Address if not on local machine
'Make sure that you give permission to log into the
'server from this address
'See [URL=http://dev.mysql.com/doc/mysql/en/adding-users.html]Adding New User Accounts to MySQL[/URL]
'Make sure that you d/l and install the [URL=http://dev.mysql.com/downloads/connector/odbc/3.51.html]MySQL Connector/ODBC 3.51 Driver[/URL] or the
'[URL=http://dev.mysql.com/downloads/connector/odbc/5.0.html]MySQL Connector/ODBC 5.0 Driver[/URL]
strServerName = "localhost"
strDatabaseName = "DatabaseName"
strUserName = "UserName"
strPassword ="Password"
ConnectString = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=" & strServerName & _
";DATABASE=" & strDatabaseName & ";" & _
"USER=" & strUserName & _
";PASSWORD=" & strPassword & _
";OPTION=3;"
End Function
Re: First Time I use MYSQL
Thank you for all the replies, the outcome? it can now be done :)
Once again thanks for a your replies, it works perfect now :)