×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

The Connection String Property has not been initialized

The Connection String Property has not been initialized

The Connection String Property has not been initialized

(OP)
I get the error in the subject when trying to run the code below.  I am new to vb.net and am trying to convert and access database to vb.net. I am trying to bind a form to this query.   Any help will be greatly appreciated.


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim CN As New SqlConnection
        Dim CNstring As String = _
                 "DATA SOURCE = \\CTIDATA; INITIAL CATALOG = JOBS; " & _
                 "Integrated Security = True"

        CNstring = InputBox( _
             "Please enter a Connection String", _
             "CONNECTION STRING", CNstring)
        If CNstring.Trim = "" Then Exit Sub

        Try
            CN.Open()
            If CN.State = ConnectionState.Open Then
                MsgBox("Workstation " & CN.WorkstationID & _
                       " connected to database " & CN.Database & _
                       " on the " & CN.DataSource & " server")
            End If

        Catch ex As Exception
            MsgBox( _
            "FAILED TO OPEN CONNECTION TO DATABASE DUE TO THE FOLLOWING ERROR" & _
            vbCrLf & ex.Message)

        End Try




        Dim CMD As New SqlCommand( _
                      "SELECT tblAccounting.PaymentTerms, tblAccounting.[FIELD PAYROLLS], tblAccounting.[TAX EXEMPT], tblAccounting.[TAX APPLIES], tblCustomer.*, tblEngineerCompany.*, " & _
                     "tblJobDetails.*, tblJobReqs.*, tblSubcontractDetails.*, tblDatesHours.* " & _
            "FROM         tblJobCustomerID INNER JOIN " & _
                     "tblCustomer ON tblJobCustomerID.CustomerID = tblCustomer.CustomerID INNER JOIN " & _
                      "tblJobDetails ON tblJobCustomerID.JobNoCus = tblJobDetails.JobNo INNER JOIN " & _
                      "tblDatesHours ON tblJobDetails.JobNo = tblDatesHours.JobNoDH INNER JOIN " & _
                      "tblAccounting ON tblJobDetails.JobNo = tblAccounting.JobNoAcct INNER JOIN " & _
                      "tblJobEngineerID ON tblJobDetails.JobNo = tblJobEngineerID.JobNoEng INNER JOIN " & _
                      "tblEngineerCompany ON tblJobEngineerID.EngineerCompanyID = tblEngineerCompany.EngineerCompanyID INNER JOIN " & _
                      "tblJobReqs ON tblJobDetails.JobNo = tblJobReqs.JobNoReq CROSS JOIN " & _
                      "tblSubcontractDetails ", CN)
        Dim Count As Integer
        CN.Open()
        Count = CMD.ExecuteScalar
        If CN.State = ConnectionState.Open Then CN.Close()

RE: The Connection String Property has not been initialized

You haven't assigned the CnString to the CN object.
you need something to the effect of:

CODE

Cn.ConnectionString = CnString

--------------------------------------------------
"Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month." --Wernher von Braun
--------------------------------------------------

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close