I am currently tryinh to have this variable declared :
Dim SQLLecteur As SqlDataReader = Command.ExecuteReader()
And receiving the following error : 'ExecuteReader' is not member of 'String'.
1. The ExecuteReader was not present in the list following the Command.
2. The variable is declared from a : Public Shared Sub
3. This sub is located in a code library referenced in the web.config as a namespace : <add namespace="PAX20070409" />
4. If used directly in the .vb file within this sub : Protected Sub btnConnection_Click, I am not receiving any errors about the Dim.
It is pretty clear why the code is not working, but I have not been able to find a way to fix the problem. I am currently trying to find a way to make the Dim work from within my code library. If you have any idea on how this could be achieve, it would be greatly apreciated.
Thank you :)
RV3
looks that you Command is declared somewhere as string or is not declared and system use string type as default
try
dim SQLCommand as sqlclient.sqlcommand = new sqlclient.sqlcommand("Your command name")
'setup connection for your command
'open your connection
Dim SQLLecteur As SqlDataReader = SQLCommand.ExecuteReader()
'close your connection
example:
Dim queryString As String = _
"SELECT OrderID, CustomerID FROM dbo.Orders;"
Using connection As New SqlConnection(connectionString)
Dim command As New SqlCommand(queryString, connection)
connection.Open()
Dim reader As SqlDataReader = command.ExecuteReader()
' Call Read before accessing data.
While reader.Read()
Console.WriteLine(String.Format("{0}, {1}", _
reader(0), reader(1)))
End While
' Call Close when done reading.
reader.Close()
End Using|||
yOUR CODE SHOULD LOOK LIEK THIS ONE
Dim queryString As String = _
"SELECT OrderID, CustomerID FROM dbo.Orders;"
Using connection As New SqlConnection(connectionString)
Dim command As New SqlCommand(queryString, connection)
connection.Open()
Dim reader As SqlDataReader = command.ExecuteReader()
' Call Read before accessing data.
While reader.Read()
Console.WriteLine(String.Format("{0}, {1}", _
reader(0), reader(1)))
End While
' Call Close when done reading.
reader.Close()
End Using
Public Shared SQLConnection As New SqlConnection(ConfigurationManager.AppSettings("BDD_LILILUX"))
Public Shared SQLCommande As SqlClient.SqlCommand = New SqlClient.SqlCommand("SQLCommande")
This is the answer, it is working marvellously fine now :)
Thank you :)
Missed a line :P
Dim SQLLecteur As SqlDataReader = SQLCommande.ExecuteReader
No comments:
Post a Comment