这是我的连接代码:
Imports System.Data.SqlClient
Public Class frm_edit_patient
Dim con As New SqlConnection
Private Sub frm_edit_patient_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
frm_dashboard.Enabled = True
Me.Hide()
End Sub
Private Sub frm_edit_patient_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Database1DataSet1.patients' table. You can move, or remove it, as needed.
Me.PatientsTableAdapter.Fill(Me.Database1DataSet1.patients)
frm_dashboard.Enabled = False
Try
Dim myConString As String = My.Settings.Database1ConnectionString
con.ConnectionString = myConString
con.Open()
con.Close()
MessageBox.Show("connected")
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
frm_dashboard.Enabled = True
Me.Hide()
End Sub
End Class
但这给了我错误:
我正在使用绑定源进行数据库连接....