Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 28-10-2009
Member
 
Join Date: Jul 2009
Posts: 81
SQL Server Express 2008 connection problem

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"

Quote:
ExecuteReader: Connection property has not been initialized.
Someone has an idea as it stops to do that (and quickly if possible)
Reply With Quote
  #2  
Old 28-10-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: SQL Server Express 2008 connection problem

By learning to read errors and considering/trying to understand a little bit. The documentation may also help: MSDN tutorials ADO.Net, ....

For
Quote:
ExecuteReader: Connection property has not been initialized.
ExecuteReader method is a DbCommand objects (SqlCommand OdbcCommand ...). The error indicates that when calling this method, the Connection property has not been initialized. Logic since command runs over a connection.

So on your SqlCommand object you must have something to initialize this connection, what you do not. If necessary, the link to the MSDN for the class.
Reply With Quote
  #3  
Old 28-10-2009
Member
 
Join Date: Jul 2009
Posts: 81
Re: SQL Server Express 2008 connection problem

Thank you for responding so quickly! I blocked the above this morning and I searched msdn and company without really finding any happiness. Ok I'll look at it more closely.
Reply With Quote
  #4  
Old 28-10-2009
Member
 
Join Date: Nov 2008
Posts: 996
Re: SQL Server Express 2008 connection problem

The ObjetConnection corresponds to Conn in your case, its your variable connection. Here are the items that need to be reported for the connection:

Code:
Private rqSql As String 'SQL string String 
Private cnxString As String 'SQL string used to accommodate the Chemain the SQL database 
Private CNX As System.Data.SqlClient.SqlConnection 'Subject connection string that contains the connection string 
CMD Target As System.Data.SqlClient.SqlCommand 'contains the connection over the SQL query 
Private da As System.Data.SqlClient.SqlDataAdapter 'Data fit, subject only connected program 
Private DS As System.Data.DataSet object cache that contains all records from the output of CMD
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "SQL Server Express 2008 connection problem"
Thread Thread Starter Forum Replies Last Post
how to manage vpn connection with IBM server 2008 vibs10 Networking & Security 1 23-08-2011 04:06 PM
SQL server 2008 R2 EXPRESS: Do not access the instance BOWIE Operating Systems 7 05-03-2011 08:16 PM
SBS 2008 Fax Server role, no fax connection Billie Small Business Server 5 15-09-2010 05:10 PM
Special features of SQL Server Express 2008 GunFighter Windows Software 3 12-08-2009 02:39 PM
Visual Basic express sql server connection shilong Software Development 3 06-08-2009 12:39 PM


All times are GMT +5.5. The time now is 07:45 PM.