3

Im new in vb.net and mysql.

I got confused when I am defining Dim SQLConnection As MySqlConnection = New MySqlConnection.

And it said that the New "MySqlConnection" is not defined but I made sure that I have imported namespace needed or anything but i still have an error and i cant figure out whats the problem.

This is my code:

 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

Any help would be appreciated. Thanks! I got confused sorry XD

Mineko
  • 641
  • 2
  • 14
  • 21

1 Answers1

4

Try:

Replace

Dim SQLConnection As MySqlConnection = New MySqlConnection

by

Dim SQLConnection As New MySqlConnection()

Other point, you may use String.Empty to set value for String instead of "".

HTH.

Thinhbk
  • 2,194
  • 1
  • 23
  • 34