tags:

views:

41

answers:

1

I am trying to retrieve a password from an SQLite database. The id of the row the password is in is 1. I want to assignt his password to a variable called actualpass.

This is as far as I got before I became stuck. Can anyone help?

Private Sub LoginButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginButton.Click
    Dim SQConnect As New SQLite.SQLiteConnection
    Dim SQCommand As New SQLite.SQLiteCommand
    Dim actualpass As String
    Dim givenname As String
    Dim path As String
    path = AppDomain.CurrentDomain.BaseDirectory()
    givenname = txtUsername.Text

    SQConnect.ConnectionString = ("Data Source=" & path & "app_data\data.db3")
    SQConnect.Open()
    SQCommand = SQConnect.CreateCommand
    SQCommand.CommandText = ("SELECT password from login_data WHERE id =1")




End Sub
+1  A: 
DataReader reader = SqCommand.ExecuteReader();

while (reader.Read()) {
   if (reader["password"] != System.DBNull) {
      actualpass = reader["password"] as string;
   } else {
      actualpass = null;
   }

   break; //only want one row and one field
}

Should be close, never used SQLite and I dont have an IDE to doublecheck syntax.

GrayWizardx
a bit of tweaking and this works :) Thanks!
Mark Provan
NP (fifteen character filler)
GrayWizardx