我是 vb.net 和 mysql 的新手。
当我将 Dim SQLConnection 定义为 MySqlConnection = New MySqlConnection 时,我感到困惑。
它说新的“MySqlConnection”没有定义,但我确保我已经导入了需要的命名空间或任何东西,但我仍然有一个错误,我无法弄清楚是什么问题。
这是我的代码:
Imports MySql.Data.MySqlClient
Public Class EditInfo
Dim bednumber As String = ""
Dim patient_name As String = ""
Dim patient_age As String = ""
Dim date_of_confinement As String = ""
Dim type_of_sickness As String = ""
Dim type_of_IV_fluid As String = ""
Dim number_of_bottles As String = ""
Dim drop_rate As String = ""
Dim ServerString As String = "Server=localhost; database=patientinfo;user id=root;password=root" 'connection to phpmyadmin database
Dim SQLConnection As MySqlConnection = New MySqlConnection
Private Sub PatientInfoBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PatientInfoBindingNavigatorSaveItem.Click
Me.Validate()
Me.PatientInfoBindingSource.EndEdit()
Me.PatientInfoTableAdapter.Update(Me.PatientInfoDBDataSet.PatientInfo)
End Sub
任何帮助,将不胜感激。谢谢!我糊涂了对不起XD
最佳答案
尝试:
代替
Dim SQLConnection As MySqlConnection = New MySqlConnection
经过
Dim SQLConnection As New MySqlConnection()
另外一点,您可以使用 String.Empty 来设置 String 而不是 ""的值。
哈。
关于MySqlConnection 未定义,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11622876/