I am developing an application in VB.Net with a database in SQL Server Express 2008. I made my connection
Code:
'definition of connection variables
Dim user As String
Dim mdp As String
Dim bdd As String
Dim server As String
Dim connstring As String
'recovery of connection variables
user = "sa"
mdp = ""
bdd = "elect_test_yln"
server = " .\SQLEXPRESS"
'filling of the variable to start the connection
connstring = "Persist Security Info = true; Integrated Security = SSPI; Data Source = " & server & "; Database = " & bdd & "; User ID = " & user & "; Password = " & mdp & ";"
'connection has the database with error handling
Try
conn = New SqlConnection(connstring)
conn.Open()
Catch e As Exception
MsgBox("The following error occurred: " & e.Message)
Finally : conn.Close()
End Try
Loading there is no problem but that I perform a query
Code:
data_parent = "select numfile, label from file"
Dim request_parent As New SqlCommand(data_parent)
reader_parent = request_parent.ExecuteReader
reader_parent.Read()
I receive the following error message that points to "reader_parent = request_parent.ExecuteReader"
ExecuteReader: Connection property has not been initialized.
Someone has an idea as it stops to do that (and quickly if possible)
Bookmarks