Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 27th, 2003, 12:53 PM
darkrealm darkrealm is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 6 darkrealm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question VB en Mysql(?)(?)(?)

is it possible to use Mysql in VB projects? and ifso how?

greetz JJ

Reply With Quote
  #2  
Old April 27th, 2003, 09:09 PM
jhb jhb is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: Portland, Oregon USA
Posts: 2 jhb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to jhb
Yes it is. You'll first need to have the MyODBC driver installed on your system. It can be found here:

URL

Then the following code (Assuming you've set a reference to use ADODB controls):

-- Begin Code --

Set objConnection = New ADODB.Connection

objConnection.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=your_server_name_here;DATABASE=your_database_name_here;UID=username_here;PWD=password _here; OPTION=16427 "

objConnection.Open

-- End Code --

Hope that helps,

jhb

Reply With Quote
  #3  
Old April 28th, 2003, 03:12 AM
darkrealm darkrealm is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 6 darkrealm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
and how can i use query's then?

Reply With Quote
  #4  
Old April 28th, 2003, 08:41 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Once you have the MyODBC driver installed and you establish an adodb connection as jhb posted, then you just use it as you would any adodb object.

Reply With Quote
  #5  
Old April 28th, 2003, 09:04 AM
darkrealm darkrealm is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 6 darkrealm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i haven't used them before :$, i've made some complicated programs but so far only stand alone. this is the first i will use with a out-source program ;-)

Reply With Quote
  #6  
Old April 28th, 2003, 09:42 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
have you used the adodb object before?

Reply With Quote
  #7  
Old April 28th, 2003, 09:45 AM
darkrealm darkrealm is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 6 darkrealm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Nope

Reply With Quote
  #8  
Old April 28th, 2003, 09:48 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught

Reply With Quote
  #9  
Old April 28th, 2003, 09:50 AM
darkrealm darkrealm is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 6 darkrealm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thnx

JJ

Reply With Quote
  #10  
Old April 28th, 2003, 02:05 PM
jhb jhb is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: Portland, Oregon USA
Posts: 2 jhb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to jhb
Here's my DataAccess class and implementation (I use arrays instead of recordsets)

-- Begin cDataAccess Class --

Option Explicit
Private objConnection As ADODB.Connection

Public Function RetrieveData(strSQL As String) As Variant

Dim objRecordset As ADODB.Recordset

'send the query to the database and return data to a Recordset object
Set objRecordset = objConnection.Execute(strSQL)

'we need to convert the recordset into an array and send it back to the calling
'only convert to an array if there is something in the recordset
If objRecordset.BOF = False Or objRecordset.EOF = False Then
RetrieveData = objRecordset.GetRows
End If

End Function

Public Sub Update(strSQL As String)

objConnection.Execute strSQL

End Sub

Public Sub Disconnect()

objConnection.Close
Set objConnection = Nothing

End Sub


Public Sub Connect()

Set objConnection = New ADODB.Connection

'Driver version needs to match version you installed
objConnection.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=your_server_name_here;DATABASE=your_database_name_here;UID=username_here;PWD=password _here; OPTION=16427 "

objConnection.Open


End Sub

-- End cDataAccess Class --

And how it would be used to bring back an array...

-- Begin Code --

Private mobjDataAccess As cDataAccess

Set mobjDataAccess = New cDataAccess

Public Function GetSomeData() As Variant

Dim strSQL As String

strSQL = "SELECT id,name from sometable"

mobjDataAccess.Connect

GetSomeData = mobjDataAccess.RetrieveData(strSQL)

mobjDataAccess.Disconnect

Set mobjDataAccess = Nothing

End Function

-- End Code --

And how to loop through that array and fill up a list box (assuming your bringing back an array with two items...for example... an id and a name)

-- Begin Code --

Public Sub FillSomeListBox()

Dim intCounter As Integer
Dim arrSomeList As Variant

arrSomeList = GetSomeData()

For intCounter = 0 To UBound(arrSomeList, 2)

lstSomeListBox.AddItem arrSomeList(1, intCounter)

lstSomeListBox.ItemData(lstSomeListBox.NewIndex) = arrSomeList(0, intCounter)
Next

End Sub

-- End Code --

Reply With Quote
  #11  
Old April 29th, 2003, 01:20 PM
computer's Avatar
computer computer is offline
echo $usertitle['computer'];
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Jan 2003
Location: UK
Posts: 6,676 computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 4 Weeks 9 h 21 m 31 sec
Reputation Power: 219
Send a message via ICQ to computer
my turn to ask :p

ok so how would I add something from some textboxes into a new record on a DB?
__________________

Reply With Quote
  #12  
Old April 29th, 2003, 02:24 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
sql = "insert into your_table values ('" & textbox1.text & "')"
objConnection.Execute sql

this is assuming that your_table only has one column

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > VB en Mysql(?)(?)(?)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |