3

我是 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

4

1 回答 1

4

尝试:

代替

Dim SQLConnection As MySqlConnection = New MySqlConnection

经过

Dim SQLConnection As New MySqlConnection()

另一点,您可以使用 String.Empty 来设置 String 而不是 "" 的值。

HTH。

于 2012-07-24T02:18:41.773 回答