help please

et_

Member
Joined
Feb 16, 2007
Messages
15
Ive visited connectionstrings.com and tried all the oledb options, but none have worked out. Either i get a named pipes error, or can not connect error.
Im using sql server 2005 express.

my code:

Code:
Testing Class
Public Class Form1
    Public WithEvents test1 As GenSchema

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dsPath As String = "C:\Documents and Settings\Administrator\Desktop\db\SignMaker_Data.MDF"
        Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
        & "Data Source= " & dsPath & ";" _
        & "Persist Security Info=False"
        Dim strConn As String = _
                "Provider=SQLNCLI;Server=BORAT\SQLEXPRESS;Database=SignMaker;Trusted_Connection=yes;"
        test1 = New GenSchema(strConn)
    End Sub

    Public Sub statChange(ByVal connectionStatus As GenSchema.dbStat) Handles test1.evStatus
        MsgBox(connectionStatus.ToString)
    End Sub

End Class
Code:
Connection class
Public Class GenSchema
    
    Public Enum dbStat
        closed
        open
        disposed
        openError
    End Enum

    Public connectionStatus As dbStat
    Public Event evStatus(ByVal connectionStatus As dbStat)

    Public Sub New(ByVal strConnPath As String)
        Open a connection object
        Dim oleConn As OleDb.OleDbConnection = Nothing
        Try
            openConnection(oleConn, strConnPath)
        Catch ex As SqlClient.SqlException
            Console.WriteLine("crap, " & ex.Message.ToString)
            connectionStatus = dbStat.openError
            RaiseEvent evStatus(dbStat.openError)
        Catch ex As Exception
            Console.WriteLine("crap, " & ex.Message.ToString)
            connectionStatus = dbStat.openError
            RaiseEvent evStatus(dbStat.openError)
        Finally
            oleConn.Close()
            connectionStatus = dbStat.closed
            RaiseEvent evStatus(connectionStatus)
            oleConn.Dispose()
            connectionStatus = dbStat.disposed
            RaiseEvent evStatus(connectionStatus)
        End Try
    End Sub

    Private Sub openConnection(ByRef oleConn As OleDb.OleDbConnection, ByVal strConnPath As String)
        oleConn = New OleDb.OleDbConnection(strConnPath)
        oleConn.Open()
        connectionStatus = dbStat.open
        RaiseEvent evStatus(connectionStatus)
    End Sub

End Class
 
Is the sqlexpress running on the same pc as your application? If not then be aware that SQLExpress only listens on the local pc by default and you will need to reconfigure it before network access is allowed.

Just out of curiosity is there a reason you are using OleDb rather than the SqlClient?
 
I found a code example using oledb.

I guess ill try sqlclient, but im still curious why everytime i use oledb i get the following error:
Could not load file or assembly System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a or one of its dependencies. The system cannot find the file specified
 
Back
Top