Jason Bodine
2013-01-21 07:20:38 UTC
Hi All!
I've been working to port an App I wrote in VB6 a while back to a .NET version using VB 2010. The program uses an Access database to store and retrieve information. My problem is, all I can get it to create is an empty database because for some reason, it doesn't seem to like the connection string and I can't figure out why. Below, I've pasted my entire module containing the Sub Main code. Could someone please take a look at it and tell me what's going wrong?
Thanks!
Jason
P.S. If this sounds familiar to anyone, it's because I a question about the same type of issues when I was using VB6. This code implements those solutions, but what's good for the goose apparently *isn't* good for the gander!! LOL
----------------------------------
Option Explicit On
Imports ADOX
Imports ADODB
Imports System.Data.OleDb
Module Start
Public cat As ADOX.Catalog
Public table As ADOX.Table
Public column As ADOX.Column
Public con As ADODB.Connection
Public cmd As ADODB.Command
Public rec As ADODB.Recordset
Public sConnection As String
Public DBPath As String
Public PicPath As String
Public Active_Profile As String
Dim Admin As Object
Public Function FileExists(ByVal fPath As String) As Boolean
If Dir(fPath) <> "" Then
FileExists = True
Else
FileExists = False
End If
End Function
Public Sub SetDB()
DBPath = Application.StartupPath & "\Profiles.mdb"
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DBPath & ";"
End Sub
Public Sub StartDB()
con = New ADODB.Connection
con.Open(sConnection, "Admin")
End Sub
Public Sub StopDB()
con.Close()
con = Nothing
End Sub
Public Sub MakeDB()
cat = New ADOX.Catalog
cat.Create(sConnection)
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DBPath & ";Jet OLEDB:Engine Type=5"
table = New ADOX.Table
With table
.Name = "User_Profiles"
.ParentCatalog = cat
column = New ADOX.Column
With column
.Name = "User_Name" '0
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Password_Protection_Enabled" '1
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "TattleTale_Enabled" '2
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "User_Password" '3
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Security_Question" '4
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Security_Answer" '5
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Email_Address" '6
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Mobile_Phone_Number" '7
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Mobile_Service_Provider" '8
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Mobile_SMS_Server" '9
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Mobile_MMS_Server" '10
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Email_Enabled" '11
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "SMS_Enabled" '12
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "MMS_Enabled" '13
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Default_Wallpaper" '14
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Document_Background_Color" '15
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Document_Font_Color" '16
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Default_Font" '17
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Default_Font_Size" '18
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Document_Left_Margin" '19
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Document_Right_Margin" '20
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Default_Profile" '21
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Toolbar_Visible" '22
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Options_Toolbar_Visible" '23
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Status_Bar_Visible" '24
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Timestamp_Entries" '25
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
End With
cat.Tables.Append(table)
table = Nothing
table = New ADOX.Table
With table
.Name = "User_Files"
.ParentCatalog = cat
column = New ADOX.Column
With column
.Name = "File_Name" '0
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Path_To_File" '1
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Date_Created" '2
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Date_Last_Modified" '3
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "File_Size" '4
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "File_Content" '5
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "File_Author" '6
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "File_Password_Enabled" '7
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "File_Password" '8
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
End With
cat.Tables.Append(table)
cat = Nothing
End Sub
Public Sub MakeAdmin()
cmd = New ADODB.Command
With cmd
.ActiveConnection = con
.CommandText = "SELECT * FROM [User_Profiles]"
.CommandType = CommandTypeEnum.adCmdText
End With
rec = New ADODB.Recordset
With rec
.CursorType = CursorTypeEnum.adOpenStatic
.CursorLocation = CursorLocationEnum.adUseClient
.LockType = LockTypeEnum.adLockOptimistic
.Open(cmd)
.AddNew()
.Fields(0).Value = Admin
.Fields(1).Value = False
.Fields(2).Value = False
.Fields(3).Value = ""
.Fields(4).Value = ""
.Fields(5).Value = ""
.Fields(6).Value = ""
.Fields(7).Value = ""
.Fields(8).Value = ""
.Fields(9).Value = ""
.Fields(10).Value = ""
.Fields(11).Value = False
.Fields(12).Value = False
.Fields(13).Value = False
.Fields(14).Value = ""
.Fields(15).Value = ""
.Fields(16).Value = ""
.Fields(17).Value = ""
.Fields(18).Value = ""
.Fields(19).Value = ""
.Fields(20).Value = ""
.Fields(21).Value = True
.Fields(22).Value = True
.Fields(23).Value = True
.Fields(24).Value = True
.Fields(25).Value = True
.Update()
End With
rec.Close()
cmd = Nothing
rec = Nothing
End Sub
Public Sub CheckForProfiles()
DBPath = Application.StartupPath & "\Profiles.mdb"
con = New ADODB.Connection
With con
.Provider = "Microsoft.Jet.OLEDB.4.0"
.CursorLocation = CursorLocationEnum.adUseClient
.Mode = ConnectModeEnum.adModeReadWrite
.Open(DBPath)
End With
cmd = New ADODB.Command
With cmd
.ActiveConnection = con
.CommandText = "SELECT * FROM [User_Profiles]"
.CommandType = CommandTypeEnum.adCmdText
End With
rec = New ADODB.Recordset
With rec
.CursorType = CursorTypeEnum.adOpenStatic
.CursorLocation = CursorLocationEnum.adUseClient
.LockType = LockTypeEnum.adLockOptimistic
.Open(cmd)
If .RecordCount > 1 Then
frmSelect.Show()
Do Until .EOF
frmSelect.cmbSelect.Items.Add(.Fields(0))
.MoveNext()
Loop
ElseIf .RecordCount = 1 Then
frmSelect.Show()
With frmSelect
.btnLoadProfile.Enabled = False
.lblSelect.Text = "Please enter a name for your new profile and click Create Profile."
End With
Else
MsgBox("No Records Found!", vbOKOnly + vbInformation, "Error")
End If
.Close()
End With
rec = Nothing
cmd = Nothing
con.Close()
con = Nothing
End Sub
Public Sub Main()
SetDB()
If Not FileExists(DBPath) Then
MakeDB()
StartDB()
MakeAdmin()
StopDB()
SaveSetting(Application.CompanyName, Application.ProductName, "Active_Profile", "Admin")
Active_Profile = GetSetting(Application.CompanyName, Application.ProductName, "Active_Profile")
CheckForProfiles()
Else
CheckForProfiles()
End If
End Sub
End Module
I've been working to port an App I wrote in VB6 a while back to a .NET version using VB 2010. The program uses an Access database to store and retrieve information. My problem is, all I can get it to create is an empty database because for some reason, it doesn't seem to like the connection string and I can't figure out why. Below, I've pasted my entire module containing the Sub Main code. Could someone please take a look at it and tell me what's going wrong?
Thanks!
Jason
P.S. If this sounds familiar to anyone, it's because I a question about the same type of issues when I was using VB6. This code implements those solutions, but what's good for the goose apparently *isn't* good for the gander!! LOL
----------------------------------
Option Explicit On
Imports ADOX
Imports ADODB
Imports System.Data.OleDb
Module Start
Public cat As ADOX.Catalog
Public table As ADOX.Table
Public column As ADOX.Column
Public con As ADODB.Connection
Public cmd As ADODB.Command
Public rec As ADODB.Recordset
Public sConnection As String
Public DBPath As String
Public PicPath As String
Public Active_Profile As String
Dim Admin As Object
Public Function FileExists(ByVal fPath As String) As Boolean
If Dir(fPath) <> "" Then
FileExists = True
Else
FileExists = False
End If
End Function
Public Sub SetDB()
DBPath = Application.StartupPath & "\Profiles.mdb"
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DBPath & ";"
End Sub
Public Sub StartDB()
con = New ADODB.Connection
con.Open(sConnection, "Admin")
End Sub
Public Sub StopDB()
con.Close()
con = Nothing
End Sub
Public Sub MakeDB()
cat = New ADOX.Catalog
cat.Create(sConnection)
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DBPath & ";Jet OLEDB:Engine Type=5"
table = New ADOX.Table
With table
.Name = "User_Profiles"
.ParentCatalog = cat
column = New ADOX.Column
With column
.Name = "User_Name" '0
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Password_Protection_Enabled" '1
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "TattleTale_Enabled" '2
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "User_Password" '3
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Security_Question" '4
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Security_Answer" '5
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Email_Address" '6
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Mobile_Phone_Number" '7
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Mobile_Service_Provider" '8
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Mobile_SMS_Server" '9
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Mobile_MMS_Server" '10
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Email_Enabled" '11
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "SMS_Enabled" '12
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "MMS_Enabled" '13
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Default_Wallpaper" '14
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Document_Background_Color" '15
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Document_Font_Color" '16
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Default_Font" '17
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Default_Font_Size" '18
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Document_Left_Margin" '19
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Document_Right_Margin" '20
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Default_Profile" '21
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Toolbar_Visible" '22
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Options_Toolbar_Visible" '23
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Status_Bar_Visible" '24
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Timestamp_Entries" '25
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
End With
cat.Tables.Append(table)
table = Nothing
table = New ADOX.Table
With table
.Name = "User_Files"
.ParentCatalog = cat
column = New ADOX.Column
With column
.Name = "File_Name" '0
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Path_To_File" '1
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Date_Created" '2
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "Date_Last_Modified" '3
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "File_Size" '4
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "File_Content" '5
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "File_Author" '6
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adVarWChar
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "File_Password_Enabled" '7
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
End With
.Columns.Append(column)
column = New ADOX.Column
With column
.Name = "File_Password" '8
.ParentCatalog = cat
.Type = ADOX.DataTypeEnum.adBoolean
.Attributes = ColumnAttributesEnum.adColNullable
End With
.Columns.Append(column)
End With
cat.Tables.Append(table)
cat = Nothing
End Sub
Public Sub MakeAdmin()
cmd = New ADODB.Command
With cmd
.ActiveConnection = con
.CommandText = "SELECT * FROM [User_Profiles]"
.CommandType = CommandTypeEnum.adCmdText
End With
rec = New ADODB.Recordset
With rec
.CursorType = CursorTypeEnum.adOpenStatic
.CursorLocation = CursorLocationEnum.adUseClient
.LockType = LockTypeEnum.adLockOptimistic
.Open(cmd)
.AddNew()
.Fields(0).Value = Admin
.Fields(1).Value = False
.Fields(2).Value = False
.Fields(3).Value = ""
.Fields(4).Value = ""
.Fields(5).Value = ""
.Fields(6).Value = ""
.Fields(7).Value = ""
.Fields(8).Value = ""
.Fields(9).Value = ""
.Fields(10).Value = ""
.Fields(11).Value = False
.Fields(12).Value = False
.Fields(13).Value = False
.Fields(14).Value = ""
.Fields(15).Value = ""
.Fields(16).Value = ""
.Fields(17).Value = ""
.Fields(18).Value = ""
.Fields(19).Value = ""
.Fields(20).Value = ""
.Fields(21).Value = True
.Fields(22).Value = True
.Fields(23).Value = True
.Fields(24).Value = True
.Fields(25).Value = True
.Update()
End With
rec.Close()
cmd = Nothing
rec = Nothing
End Sub
Public Sub CheckForProfiles()
DBPath = Application.StartupPath & "\Profiles.mdb"
con = New ADODB.Connection
With con
.Provider = "Microsoft.Jet.OLEDB.4.0"
.CursorLocation = CursorLocationEnum.adUseClient
.Mode = ConnectModeEnum.adModeReadWrite
.Open(DBPath)
End With
cmd = New ADODB.Command
With cmd
.ActiveConnection = con
.CommandText = "SELECT * FROM [User_Profiles]"
.CommandType = CommandTypeEnum.adCmdText
End With
rec = New ADODB.Recordset
With rec
.CursorType = CursorTypeEnum.adOpenStatic
.CursorLocation = CursorLocationEnum.adUseClient
.LockType = LockTypeEnum.adLockOptimistic
.Open(cmd)
If .RecordCount > 1 Then
frmSelect.Show()
Do Until .EOF
frmSelect.cmbSelect.Items.Add(.Fields(0))
.MoveNext()
Loop
ElseIf .RecordCount = 1 Then
frmSelect.Show()
With frmSelect
.btnLoadProfile.Enabled = False
.lblSelect.Text = "Please enter a name for your new profile and click Create Profile."
End With
Else
MsgBox("No Records Found!", vbOKOnly + vbInformation, "Error")
End If
.Close()
End With
rec = Nothing
cmd = Nothing
con.Close()
con = Nothing
End Sub
Public Sub Main()
SetDB()
If Not FileExists(DBPath) Then
MakeDB()
StartDB()
MakeAdmin()
StopDB()
SaveSetting(Application.CompanyName, Application.ProductName, "Active_Profile", "Admin")
Active_Profile = GetSetting(Application.CompanyName, Application.ProductName, "Active_Profile")
CheckForProfiles()
Else
CheckForProfiles()
End If
End Sub
End Module