If you see this "ExecuteReader: Connection property has not been initialized" message. This problem occur when your command does not associate with any connection.
Here is a snippet sample to recreate the error:
Conn = New SqlConnection
Conn.ConnectionString = connectionString
Command = New SqlCommand(sql)
Conn.Open()
dgResults.DataSource = Comamnd.ExecuteReader()
dgResults.DataBind()
Conn.Close()
"Error occur because the command is not associate with any connection"
Below is the solution:
1. Command = new SqlCommand(sql,Conn)
2. Command = new SqlCommand(sql)
Command.Connection = conn
Friday, March 6, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
-->Please Share your experience with me<--