我已经四处寻找,但却无法找到任何可行的方法。
答案 0 :(得分:2)
您需要安装Connector/Net,这将为您提供可供您使用的MySql的完整ADO.Net提供程序。请注意,这是GPL软件,这意味着如果您将其作为商业产品的一部分分发,您还必须分发您的源代码。这是一个公开的法律问题,但最后我听说大多数网站都没问题,因为你没有分发你的服务器代码。但桌面应用可能存在问题。
答案 1 :(得分:2)
Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient
Public Class LoginForm1
Dim MySQLConnection As MySqlConnection
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Close()
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Close()
End Sub
Private Sub Cancel_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
End
End Sub
Private Sub OK_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
MySQLConnection = New MySqlConnection
MySQLConnection.ConnectionString = "server=db4free.net;Port=3306; User ID=db4freeusername; password=db4freepassword; database=nameofyourdatabase"
MySQLConnection.Open()
Dim MyAdapter As New MySqlDataAdapter
Dim SqlQuary = "SELECT * From nameofthetable WHERE Username='" & UsernameTextBox.Text & "' AND password = '" & PasswordTextBox.Text & "';"
Dim Command As New MySqlCommand
Command.Connection = MySQLConnection
Command.CommandText = SqlQuary
MyAdapter.SelectCommand = Command
Dim Mydata As MySqlDataReader
Mydata = Command.ExecuteReader
If Mydata.HasRows = 0 Then
MsgBox("Error During Login:Please Enter Valid Data")
Else
Form1.Show()
Me.Hide()
End If
End Sub
End Class
答案 2 :(得分:1)
首先,您需要安装MySQL connector for .NET。
Imports MySql.Data.MySqlClient
Dim myConnection As MySqlConnection = New MySqlConnection()
Dim myConnectionString As String = "Server=SERVERNAME;Database=DATABASE;Uid=root;Pwd=password;"
myConnection.ConnectionString = myConnectionString
myConnection.Open()
//execute queries, etc
myConnection.Close()
答案 3 :(得分:0)
我使用C#:
const String ConnectionString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Port=3306;Database=test;User=root;Password=;Option=3;";
OdbcConnection conn = new OdbcConnection(ConnectionString);
conn.Open();
OdbcCommand command = new OdbcCommand();
command.CommandType = CommandType.StoredProcedure;
command.Connection = conn;
command.CommandText = "insert into search (tempsearchKey, state, suburb) values ('" + tempsearchKey+"','"+state+"','"+suburb+"')";
command.ExecuteNonQuery();
command.Cancel();
从mysql网站安装odbc驱动程序
并将其转换为VB.NET,
也许这个链接可以提供帮助:
http://dev.mysql.com/tech-resources/articles/ebonat-load-and-search-mysql-data-using-vbnet-2005.html
答案 4 :(得分:0)
安装用于.NET的MySQL连接器和APACHE,也安装XAMPP,以便您可以使用phpMyAdmin