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