-2
我想創建並保存在我的數據庫中的配置文件詳細信息,但我得到一個錯誤,說:「ExecuteReader需要一個開放和可用的連接。關閉。任何幫助,將不勝感激。這是我的代碼。ExecuteReader需要一個開放和可用的連接VB.NET
Imports System.Data.OleDb
Public Class Profile
Public profileConnection As New OleDbConnection
Public profileCommand As New OleDbCommand
Dim anewProfile As New PlayerProfile()
Private Sub CreateProfileButton_Click(sender As Object, e As EventArgs) Handles CreateProfileButton.Click
profileCommand.Connection = profileConnection
profileCommand.CommandText = "select Email from Players where Email = '" & EmailTextBox.Text & "'"
Dim profileDataReader As OleDbDataReader = profileCommand.ExecuteReader() 'getting error on this line
If profileDataReader.Read() Then
MsgBox("This email already exits.")
profileDataReader.Close()
Exit Sub
End If
你在哪裏打電話profileConnection.Open? – Steve
我不認爲我叫 – Sharukh
這段代碼很瘋狂 - 容易受到SQL注入攻擊。它實際上是乞求被黑客攻擊。 –