0
我想我的本地.mdf文件连接到vb.net这个参数异常弹出“关键字不支持参数名:attachdbfilename”如何将我的.mdf数据库连接到vb.net?
这里是我的代码
Imports MySql.Data.MySqlClient
Public Class Form1
Dim con As MySqlConnection
Private Sub PictureBox1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
con = New MySqlConnection
con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\almond\Desktop\TICKETING SYSTEM\TICKETING SYSTEM\Database1.mdf;Integrated Security=True;User Instance=True"
Try
con.Open()
MessageBox.Show("Connected!")
con.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
con.Dispose()
End Try
End Sub
您将需要Microsoft SQL的SqlConnection类。 MySQL是不同的。 –