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!

VB to mySQL connection

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi, I am using a simple visual basic form to to insert records into mySQL. Is there any way to connect without installing myODBC drivers and setting up a DSN on each client workstation. I don't want to have to do this on 200 workstations in our office. Thanks.
 
use the broswer and let the server handle the one connection needed...via intranet, can always use a com object to manipulate the data if needed beofre insertion...

Bastien Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Here is a little example to add a record using visual basic and MySQL.
'-------------------------------------------------
Sub AddEmployee(CURRENT_USER_ID as integer)
Dim myConn As New ADODB.Connection
Dim myRS As New ADODB.Recordset
myConn.Open MySQLConn
myRS.Source = "SELECT EmployeeID FROM TimeCard " & _
"WHERE EmployeeID = " & CURRENT_USER_ID
Set myRS.ActiveConnection = myConn
myRS.CursorLocation = adUseClient
myRS.Open , , adOpenDynamic, adLockOptimistic

If myRS.recordcount = 0 Then
'Add new employee
myRS.AddNew
myRS!EmployeeID = CURRENT_USER_ID
myRS.UpdateBatch adAffectAll
Else
msgbox "Employee already exists!"
End If
myRS.Close
myConn.Close
Set myRS.ActiveConnection = Nothing
End Sub
'---------------------------------------------
This will check to see if the EmployeeID already exists, if it doesn't it adds it to the table.

Aaron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top