Jul 26, 2008

Mysql In Visual Basic - Mysql in visual basic

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > VB Programming

free web hosting

Mysql In Visual Basic - Mysql in visual basic

it01y2
I'm am trying to create a script so that visual basic 6 can interact with mysql

Any ideas?

Reply

Galahad
It is quite possible to do that, I built several projects that connect to MySQL databases, one of them actually connecting to MySQL server here, on Trap17, on my hosted account... It works pefectly...

You need to download MyVbQL project, from Planet Source Code, and compile it into a dll, or include it directly in your project, and easily use it as a class...

Here's the link on Planet Source Code -> MyVbQL

Or a new project site: VbMySQL

Library has 4 classes:
MYSQL_CONNECTION -> Provides connectivity to MySQL server
MYSQL_RS -> Provides access to recordsets(tables) within MySQL database
MYSQL_FIELD -> Provides access to fields within MySQL table
MYSQL_ERR -> Provides access to error object, to see if any MySQL errors occured

You can access tables fields same as you would access a variable declared as a Collection:
Recordset.Fields("fieldname").Value
Recordset.Fields(fieldindex).Value

As the library is open source, when you get the source code, you will see all the properties of all four classes in the project... I'd recommend downloading it from PSC, as VbMySQL site didn't have a download available when I last looked at it...

Here's a small example how I use this great library in my projects:

CODE
'Here I create a variable named MySQL as a new connection object for MySQL
Global MySQL As New MySQL_CONNECTION

Private Function MySQL_Connect() As Boolean
Dim res_MySQL As MYSQL_CONNECTION_STATE

MySQL_Connect = False
res_MySQL = MySQL.OpenConnection("server", "username", "password", "database", 3306, CLIENT_COMPRESS)

If res_MySQL = MY_CONN_OPEN Then
  MySQL_Connect = True
End Function

' Query -> MySQL query to execute.
' CloseRS -> Optional. Close recordset created after executing Query.
' RS -> Optional. Reference to externaly created variable, declared as MYSQL_RS. If not closed, it will be available to the program after the query is executed.
' lAffected -> Optional. Numer of rows affected after te Query.
Public Sub SQLQuery(ByVal Query As String, Optional ByVal CloseRS As Boolean = False, Optional ByRef RS As MYSQL_RS, Optional ByRef lAffected As Long)
  Dim ERR As MYSQL_ERR

  Set RS = MySQL.Execute(Query, lAffected)
  Set ERR = MySQL.Error

  If ERR.Number <> 0 Then
    ' Handle any eventual errors that occurred during MySQL query
  End If
  ERR.Clear
  Set ERR = Nothing

  If CloseRS Then
    RS.CloseRecordset
    Set RS = Nothing
  End If
End Sub

Public Sub DisplayData(ByRef RS As MYSQL_RS)
  Dim p_Date As Date
  If RS.RecordCount > 0 Then
    p_Date = FromUnixTime(RS.Fields("date").value)
    lblDate.Caption = Format(p_Date, "dd. mmmm yyyy")
    txtTitle.Text = UTF8.UTF8ToANSI(RS.Fields("title").value)
    txtDescription.Text = UTF8.UTF8ToANSI(RS.Fields("describe").value)
    txtContent.Text = UTF8.UTF8ToANSI(RS.Fields("content").value)
  End If
  
  RS.CloseRecordset
  Set RS = Nothing
End Sub


If you need any help with this code, feel free to contact me... Happy connecting smile.gif

 

 

 


Reply

xplorer-ex
thanks for that post, i will also find this handy. i could use this in a future project of mine

thanks,
Xp10r3r_3X

Reply

iGuest
Question
Mysql In Visual Basic

Are codes for linking vb 6.0 form to all versions of sql same?

-question by asogol

Reply

Galahad
QUOTE(FeedBacker @ Feb 9 2008, 04:36 PM) *
Question

Mysql In Visual Basic
Are codes for linking vb 6.0 form to all versions of sql same?

-question by asogol


If I understood you correctly, you want to link entire form to a database object? Well, that is not possible with MySQL library I mentioned above, but I suppose it could be done using ADO... Only, I don't like to use ADO, so I can't help you with that, but at least I can give you that pointer - look for it using ADO...

Although, I don't see why one wouldn't use this library, it's small, fast, and it works... As far as I know it connects to MySQL 4.x and 5.x, possibly even 3.x... It all depends on MySQL maintaining libmysql.dll compatibility, and keeping all the functions within...

It does take some programming to display and update the data from MySQL, but hey, you can't have it all with zero effort...

Reply

iGuest
about View,function,preceddure
Mysql In Visual Basic

I want to develop one project in vb and mysql and now I want to use view,function and procedure so plese help me and give me a code if it is possible thanking you

-question by Ashish Dudhatra

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. connect to mysql with vb 2008 - 0.05 hr back. (1)
  2. visual basic 6 mysql - 0.38 hr back. (1)
  3. mysql vb 2008 - 2.43 hr back. (1)
  4. sample visual basic 2008 express mysql connection - 4.44 hr back. (1)
  5. connecting visual basic 6 to mysql tutorial - 5.16 hr back. (1)
  6. mysql query compare text vb - 6.12 hr back. (1)
  7. can visual studio access mysql - 7.57 hr back. (1)
  8. visual basic 2008 mysql example - 7.93 hr back. (1)
  9. visual basic and mysql - 8.24 hr back. (1)
  10. mysql_connect visual basic 6 - 10.79 hr back. (1)
  11. mysql access vba connect query - 14.31 hr back. (1)
  12. vb mysql update string byte - 16.01 hr back. (1)
  13. executing mysql query in vb - 17.04 hr back. (1)
  14. example of vb6 mysql - 17.54 hr back. (1)
Similar Topics

Keywords : mysql, visual, basic, mysql, visual, basic

  1. Vb Select Mysql Database
    (2)
  2. Beginning Visual Basic
    (4)
    CAn anyone give me a guide on VB? I've decided to learn it and I need something to work with....
    thanks ....
  3. My Guidewriter
    Simple Visual Basic program to aid in making guides (3)
    I wrote this about 3 months ago for a different forum (Runescape Forums, one I'm currently a
    G-Mod of. ) and I figured I'd share it with you. All it is, is a text editor with built in
    buttons and menus for adding BBCodes. For example, if you wanted to make something bold, you type
    what you want, highlight it, find bold in the text menu and click it. The nicest thing is, you
    can save, and you don't have to worry about a forum failing after taking hours to write a guide.
    I highly suggest you try it if you write guides often, the members on RsForums really lo....
  4. Some Visual Basic 6.0 Uncompleted Projects
    (2)
    hi friends, i have some good complete and incomplete projects in visual basic 6.0. and now i
    want to sale them for some credit points. 100 credit points only....
  5. Visual Basic And Internet Transmission
    is it possible to encrypt a http request? (2)
    I've used VB before which is why im asking this in the VB forum and not any other forum because
    i know with any other language other than PHP i have no chance so i dont actually know if this is
    possible with VB WHat i want to do is change a HTTP request that is sent to a server so that a web
    filter cannot understand it and block the request. Before anyone says that i shouldnt do that its
    hacking etc...its not...im only doing it to see if it can be done. if i wanted to get around a
    filter i wouldnt bother making my own tool I'd use someone else (skript kiddy-ish ....
  6. Visual Basic 6
    (5)
    Well currently I have the working model edition for Visual Basic 6.0 which won't allow me to
    make .exe files. I was looking into buying the Learning Edition but I can't find it cheap or in
    stock anywhere. I want to try and find it for under $100 used or new. If anyone has it, and
    would like to make the .exe file for me if I send you the files that would be great, or if anyone
    could help me find it for cheap.....
  7. Visual Basic Express Edition Beta
    How does it work? (2)
    Hey, I'm using (sorta) Visual Basic Express Edition Beta 2 (long name, eh?), but I can't
    find any good tutorials on it; all of them are for visual basic.net... Is this the same thing? I
    don't think so, and if I'm right, where can I go to get help for it?....
  8. Visual Basic 6.0 Help Needed
    Adding lines to a textbox without delete (13)
    I need help with Visual Basic 6.0 and adding lines to a textbox without deleting any previous
    lines.. I've gotten as far as finding a way to add the lines, but it deletes the prevous entree.
    Help is appreciated!....
  9. Linking To Mysql From Vb
    (6)
    Hi I have used vb to link to an access 2003 database using the adodc component- (connection string
    etc etc). Right I am now working with mysql (which I would like to say I am loving it) and I have
    migrated the access 2003 db's into mysql using the migration toolkit . How can I link to mysql
    db in a similar fashion. Please reply. Thanx. kvarnerexpress....
  10. Lost Connection To Mysql Server During Query [
    Please, Help!! (1)
    Hello Everyone... I need to put in the images table of the DB, 10 pictures of 60kb each one, when i
    do that, i lost the connection, but if a upload 10 pictures of 30kb each one, i haven't got the
    problem. I'm getting the following error when I run my select query within my VB code: Lost
    connection to MySQL server during query. This seems like a timeout error to me, but I don't
    know how to compensate so that it doesn't time out. My VB code is using Microsoft's OLE DB
    provider for ODBC, and mysql's odbc connector. Any suggestions would be g....
  11. Free Copy Of Visual Studio.net Pro
    STUDENTS ONLY (11)
    Visit THE SPOKE for your free copy of Visual Studio.NET.....
  12. [tutorial] Visual Basic 6 Minimize To Tray
    Minimize to Tray (4)
    This example will "minimize" your program to the system tray when you click on a button, and restore
    it when you click the system tray icon. For this example you'll need: 1 Form - Form1 1 button -
    Command1 Add a Module to your project, and ad this code: CODE ' Create an Icon in System
    Tray Needs Public Type NOTIFYICONDATA cbSize As Long hwnd As Long uId As Long uFlags As Long
    uCallBackMessage As Long hIcon As Long szTip As String * 64 End Type Public Const NIM_ADD = &H0
    Public Const NIM_MODIFY = &H1 Public Const NIM_DELETE = &H2 Public Const WM_MOUSEMOVE ....
  13. [tutorial] Visual Basic 6 Removing List Duplicates
    Removing List Duplicates (2)
    Removing duplicates from lists is something that you'll have to put up with if you're, say,
    parsing names off Outwar. Many delete-duplicate for...next loops are very slow, especially when you
    have thousands of names to loop through several thousand times for each name on the list. This
    function that I made is, in my opinion, the best and quickest way to do it without too many annoying
    and slow for loops (good for lists 1k +). It compares lstA to lstB. Anything that is in both lists
    is added to lstC. To change it so that anything that isn't in both lists is ....
  14. [tutorial] Visual Basic 6 Downloading Images From A Webpage
    Downloading Images from a webpage (2)
    Here's how to grab an image off the internet easily. You'll need an Inet on your form to do
    this. You can always get rid of your string variables and substitute the actual strings: Code:
    CODE Dim localFile As String Dim remoteFile As String Dim fNum As Long Dim b() As Byte
    remoteFile = "http://www.site.com/image.jpg" localFile = "C:\image.jpg"
          fNum = FreeFile b() = Inet1.OpenURL(remoteFile, icByteArray) Open
    localFile For Binary As #fNum Put #fNum, , b() Close #fNum MsgBox "Done....

    1. Looking for mysql, visual, basic, mysql, visual, basic

Searching Video's for mysql, visual, basic, mysql, visual, basic
advertisement



Mysql In Visual Basic - Mysql in visual basic



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE