2009-12-21 40 views
1

我試圖從SQLite數據庫中檢索密碼。密碼所在行的ID是1.我想將他的密碼分配給一個名爲actualpass的變量。從SQLite數據庫中進行選擇並將其分配給變量

這是就在我陷入困境之前。誰能幫忙?

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

應該是接近的,從未使用SQLite和我沒有一個IDE到雙檢語法。

+0

有點調整,這工作:)謝謝! – 2009-12-21 23:59:59

+0

NP(十五個字符填充符) – GrayWizardx 2009-12-22 00:42:30

相關問題