问题将MySQL数据库连接到我的VB 2010项目 [英] Problem Connnecting MySQL Database to my VB 2010 project
问题描述
我需要帮助将mysql数据库(mysherpherd)连接到我在Visual Studio 2010中创建的可视化基础项目的代码。目前我创建了所有接口及其各自的属性。我的目的是存储有关我教会成员的信息。谢谢
你。
嗨
用于连接任何数据库(DBMS)在.NET中,您可以使用ADO.NET,因此首先需要一个连接字符串,然后使用连接字符串,您需要一个连接对象。对于sql server你可以使用SqlCilent库和其他数据库一样的MySql你可以使用.NET的Odbc库代码说明它。
私有 Sub Form1_Load( ByVal sender 作为 对象, ByVal e As System.EventArgs)
Dim ConnectionString As 字符串 = Driver = {MySQL}; SERVER =。; DATABASE = NorthwindMySQL; '
Dim conn 作为 新 OdbcConnection(ConnectionString)
conn 。开()
Dim dataAdap 作为 新 OdbcDataAdapter( SELECT CustomerID,ContactName,ContactTitle FROM Customers,conn)
Dim 数据集作为 新数据集( Cust)
dataAdap .Fill(dataset, Customers)
MyGrid.DataSource = dataset.DefaultViewManager
conn.Close()
结束 Sub ' Form1_Load
欲了解更多信息,请查看: http://sourceforge.net/projects/vb-net-to-mysq l / [ ^ ]
并获取有关连接字符串的更多信息,请检查它: http://connectionstrings.com/ [ ^ ]
最好的问候。
转到连接 [ ^ ]
Hi, I need help on the codes to connect mysql database(mysherpherd) to a visual basic project I created in Visual Studio 2010. At the moment I have created all the interfaces and their respective properties. My intention is to store information about my church members. thank
you.
Hi
For connecting to the any database(DBMS) in .NET you can use ADO.NET so for this purpose first of all you need a connection string after that for using a connection string you need a connection object. For sql server you can use SqlCilent library and for other database same as MySql you can use Odbc library from .NET follow of codes illustrate it.
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim ConnectionString As String = "Driver={MySQL};SERVER=.;DATABASE=NorthwindMySQL;" ' Dim conn As New OdbcConnection(ConnectionString) conn.Open() Dim dataAdap As New OdbcDataAdapter("SELECT CustomerID, ContactName, ContactTitle FROM Customers", conn) Dim dataset As New DataSet("Cust") dataAdap .Fill(dataset , "Customers") MyGrid.DataSource = dataset.DefaultViewManager conn.Close() End Sub 'Form1_Load
Fro more information please check the: http://sourceforge.net/projects/vb-net-to-mysql/[^]
and for get more information about connection strings check it: http://connectionstrings.com/[^]
Best Regards.
Go To Connections[^]
这篇关于问题将MySQL数据库连接到我的VB 2010项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!