gpt4 book ai didi

未定义 MySqlConnection

转载 作者:可可西里 更新时间:2023-11-01 08:06:52 27 4
gpt4 key购买 nike

我是 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 的值而不是 ""。

HTH.

关于未定义 MySqlConnection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11622876/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com