Results 1 to 4 of 4

Thread: SQL Server Express 2008 connection problem

  1. #1
    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"

    ExecuteReader: Connection property has not been initialized.
    Someone has an idea as it stops to do that (and quickly if possible)

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    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
    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.

  3. #3
    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.

  4. #4
    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

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,173,071.42614 seconds with 17 queries