Click here to Skip to main content
15,892,965 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: byte array to string Pin
Nick Otten21-Jun-12 2:43
Nick Otten21-Jun-12 2:43 
QuestionPassword Storage Class Pin
flinchy318-Jun-12 4:31
flinchy318-Jun-12 4:31 
AnswerRe: Password Storage Class Pin
908236518-Jun-12 6:26
908236518-Jun-12 6:26 
GeneralRe: Password Storage Class Pin
flinchy318-Jun-12 7:28
flinchy318-Jun-12 7:28 
GeneralRe: Password Storage Class Pin
908236519-Jun-12 5:29
908236519-Jun-12 5:29 
GeneralRe: Password Storage Class Pin
flinchy321-Jun-12 4:17
flinchy321-Jun-12 4:17 
GeneralRe: Password Storage Class Pin
908236521-Jun-12 5:30
908236521-Jun-12 5:30 
GeneralRe: Password Storage Class Pin
908236522-Jun-12 10:39
908236522-Jun-12 10:39 
Ok, here we go. All the code you need to set up a simple database and a subroutine to add new records to which you can pass values without the need to change any existing code. You need to add a DataGridView for display. It's not the most elegant but it's the easiest to set up. When you're familiar with the code you can try something more sophisticated.

VB
Imports ADOX

Public Class Create
    'This holds the data from the database for processing in the program
    Dim DBSet As New DataSet
    Dim DBAdaptor As OleDb.OleDbDataAdapter
    Dim DBTable As DataTable
    Dim DBView As DataView
    'This will give access to the database (open to read/write, close to end transaction)
    Dim DBCon As New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = ScoreDB.mdb")
    'This passes commands to database
    Dim DBCommand As OleDb.OleDbCommandBuilder

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        'If database doesn't exist create new database (first use)
        If Not My.Computer.FileSystem.FileExists("ScoreDB.mdb") Then
            Dim DBCat As New Catalog()
            DBCat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _
                    "Data Source=ScoreDB.mdb;" & _
                    "Jet OLEDB:Engine Type=5")
            'Add table and define fields
            Dim DBCmd As New OleDb.OleDbCommand("CREATE TABLE [High_Score] ([Name] TEXT(30), [Score] NUMERIC(10))", DBCon)
            'Open database and complete update
            DBCon.Open()
            DBCmd.ExecuteNonQuery()
            DBCon.Close()
        End If

        'Fill dataset from database (all uses)
        DBCon.Open()
        Dim DBAdaptor As New OleDb.OleDbDataAdapter("SELECT * FROM High_Score", DBCon)
        DBAdaptor.Fill(DBSet, "High_Score")
        DBCon.Close()

        'Fill datatable & provide dataview to facilitate sorting

        Dim DBView As New DataView(DBSet.Tables(0))
        'Sort highest score first, alphabetical if scores identical
        DBView.Sort = "Score DESC, Name ASC"
        'Display
        DataGridView1.DataSource = DBView

    End Sub

    Private Sub DataUpdate(ByVal Name As String, Score As Integer)
        Dim DBAdaptor As New OleDb.OleDbDataAdapter("SELECT * FROM High_Score", DBCon)
        'Command builder translates adapter commands for database
        Dim DBCommand As New OleDb.OleDbCommandBuilder(DBAdaptor)
        Dim DBRow As DataRow

        DBRow = DBSet.Tables("High_Score").NewRow()
        DBRow.Item("Name") = Name
        DBRow.Item("Score") = Score

        DBSet.Tables(0).Rows.Add(DBRow)

        DBAdaptor.Update(DBSet, "High_Score")


    End Sub

End Class

GeneralRe: Password Storage Class Pin
flinchy328-Jun-12 1:20
flinchy328-Jun-12 1:20 
GeneralRe: Password Storage Class Pin
flinchy328-Jun-12 1:25
flinchy328-Jun-12 1:25 
QuestionHow to get session state in VB.NET desktop app Pin
ilgrongo18-Jun-12 3:38
ilgrongo18-Jun-12 3:38 
AnswerRe: How to get session state in VB.NET desktop app Pin
Dave Kreskowiak18-Jun-12 10:53
mveDave Kreskowiak18-Jun-12 10:53 
GeneralRe: How to get session state in VB.NET desktop app Pin
ilgrongo18-Jun-12 13:04
ilgrongo18-Jun-12 13:04 
GeneralRe: How to get session state in VB.NET desktop app Pin
Dave Kreskowiak18-Jun-12 14:51
mveDave Kreskowiak18-Jun-12 14:51 
GeneralRe: How to get session state in VB.NET desktop app Pin
ilgrongo18-Jun-12 19:52
ilgrongo18-Jun-12 19:52 
QuestionWindows 7 Lock app Pin
flinchy316-Jun-12 2:42
flinchy316-Jun-12 2:42 
AnswerRe: Windows 7 Lock app Pin
Dave Kreskowiak16-Jun-12 3:42
mveDave Kreskowiak16-Jun-12 3:42 
GeneralRe: Windows 7 Lock app Pin
flinchy316-Jun-12 16:21
flinchy316-Jun-12 16:21 
GeneralRe: Windows 7 Lock app Pin
Dave Kreskowiak16-Jun-12 17:26
mveDave Kreskowiak16-Jun-12 17:26 
AnswerRe: Windows 7 Lock app [fixed] Pin
Eddy Vluggen16-Jun-12 10:38
professionalEddy Vluggen16-Jun-12 10:38 
GeneralRe: Windows 7 Lock app Pin
Richard Andrew x6416-Jun-12 10:57
professionalRichard Andrew x6416-Jun-12 10:57 
GeneralRe: Windows 7 Lock app Pin
Eddy Vluggen16-Jun-12 11:11
professionalEddy Vluggen16-Jun-12 11:11 
GeneralRe: Windows 7 Lock app [fixed] Pin
flinchy316-Jun-12 16:48
flinchy316-Jun-12 16:48 
AnswerRe: Windows 7 Lock app [fixed] Pin
Eddy Vluggen17-Jun-12 0:06
professionalEddy Vluggen17-Jun-12 0:06 
GeneralRe: Windows 7 Lock app [fixed] Pin
flinchy318-Jun-12 3:12
flinchy318-Jun-12 3:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.