How to operate MySQL Databases in VB. NET

Source: Internet
Author: User

This is a class library written in VB. NET to connect to MySQL. You can use this class library to directly operate MySQL databases.
  
Before using this class library, you must install
ODBC MySQL 3.51: http://www.mysql.com/downloads/api-myodbc-3.51.html
Driver ODBC. Net: http://www.microsoft.com/downloads/details. aspx? Familyid = 6ccd8427-1017-4f33-a062-d165078e32b1 & displaylang = en
  
There are three classes in this library:
Manipstringformysql: This class modifies the sgbd string
Mysql_requettes: send a request
Mysql_utils: Test sgbd data
  
The following is an example of using this library to operate MySQL.
 

Code:
  1. 'Operate Dataset
  2. Public shared function mydbcdataset (byval reqsql as string ,_
  3. Byval labase as string, byval server as string ,_
  4. Byval password as string, byval user as string ,_
  5. Byval nomdataset as string) as Dataset
  6. 'Xxion à un server MySQL
  7. 'Avec le driver ODBC 3.51 avec requette qui renvoie UN Dataset
  8. Dim myconstring as string = _
  9. "Driver = {MySQL ODBC 3.51 driver}; server =" & server _
  10. & "; Database =" & labase & "; uid =" & User _
  11. & "; Password =" & password & "; option = 3 ;"
  12. Dim mydbcconnexion as new odbcconnection (myconstring)
  13. Try
  14. Dim ds as new dataset ()
  15. Dim cmd as odbcdataadapter = new
  16. Odbcdataadapter (reqsql, myconstring)
  17. Dim mycommand as new odbccommand ()
  18. Dim mydatareader as odbcdatareader
  19. Cmd. Fill (DS, nomdataset)
  20. Mydbcconnexion. Close ()
  21. Return DS
  22. Catch mydbcexception as odbcexception
  23. '
  24. Httpcontext. Current. response. Write (mydbcexception. tostring)
  25. Catch myexception as exception
  26. '
  27. Httpcontext. Current. response. Write (myexception. tostring)
  28. End try
  29. End Function
  30. 'Call the Function
  31. Dim mondatasettemp as dataset = mysql_requettes.mydbcdataset (
  32. SQL,
  33. Constantes. odbcbase,
  34. Constantes. odbcserver,
  35. Constantes. odbcpwd,
  36. Constantes. odbcuser,
  37. "Mondataset ")

The class library used by this program can be downloaded at the address below: http://www.codeproject.com/dotnet/MySQLConnexion/MySQLConnexion.zip

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.