same with Access?

It's the same concept, except you use an Access database instead. Also since you say it's an external database, that means you simply provide the ConnectionString in the My.Settings then the xsd wizards will work the same as in this example.
 
Thanks for the quick response. I've done what you advised me to but the following message interrupts during run time:
The database file may be corrupted. Run the repair utility to check the database file. [ Database name = <output ommitet>...\bin\Debug\Library Full.accdb ]
 
Try: |DataDirectory|\LibraryFull.accdb as in:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\LibraryFull.accdb;Persist Security Info=True;
 
Again the same message is pops. I'm using Visual Studio 2008.
Here is my code:
VB.NET:
Imports System.Data.SqlServerCe


Public Class frmLogIn
    Dim con As SqlCeConnection = New SqlCeConnection("Data Source=|DataDirectory|\Library Full.accdb")
    Dim Clear As Double
    Dim myDA As SqlCeDataAdapter
    Dim myDataSet As DataSet
    Dim dt As New DataTable()

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        con.Open()
        Try
            Dim cmd As SqlCeDataAdapter = New SqlCeDataAdapter("SELECT firstName,Password FROM Members WHERE Username ='" & txtUserID.Text & "' AND Password ='" & txtPassLogIN.Text & "'", con)
            cmd.Fill(dt)
            If dt.Rows.Count = 0 Then
                MessageBox.Show("Login failed, please try again.")
                cmd = Nothing
                dt.Clear()
            ElseIf dt.Rows.Count = 1 Then
                MessageBox.Show("Login worked...")
                cmd = Nothing
                dt.Clear()
            End If
        Catch ex As Exception

        End Try
        If con.State <> ConnectionState.Closed Then
            con.Close()
        End If
    End Sub

And the ConnectionString:
VB.NET:
 <Global.System.Configuration.ApplicationScopedSettingAttribute(),  _
         Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         Global.System.Configuration.SpecialSettingAttribute(Global.System.Configuration.SpecialSetting.ConnectionString),  _
         Global.System.Configuration.DefaultSettingValueAttribute("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=""|DataDirectory|\Library Full.accdb"& _ 
            """")>  _
        Public ReadOnly Property Library_FullConnectionString() As String
            Get
                Return CType(Me("Library_FullConnectionString"),String)
            End Get
 
2 things, for Access databases you use an Oledb connection (not SqlConnection/SqlCeConnection) and when you declare the instance of it you pass it the full connection string:
VB.NET:
Dim con As OledbConnection = New SqlCeConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\LibraryFull.accdb;Persist Security Info=True;")
 
I've changed the connection + the adapter and voala - no runtime errors BUT nothing happens.. when I click the button it just stays 'clicked' wow..
I think we are flooding the thread with my personal problems...

EDIT: OMG my mistake I got a spelling mistake.. in the SQL statement :confused:
Thanks for the help JuggaloBrotha I appreciate it! :]
 
Last edited:
Back
Top