1
如何将查询结果分配给变量。如何为查询结果分配变量
我正在使用SQLlite。以下是从用户表中检索密码的代码。我需要比较给定的密码和给定的密码。
Dim i As String
Dim p As String
i = txtUserID.Text
p = txtPassword.Text
Try
Dim sqlConnection As New SQLite.SQLiteConnection()
Dim sqlCommand As New SQLiteCommand("", sqlConnection)
Dim sqlPath As String = "Data Source=" & Application.StartupPath & "\Database\SimpleDB.db3"
Dim sqlQuery As String = "SELECT Password FROM User WHERE UserID LIKE '" & i & "'"
sqlConnection.ConnectionString = sqlPath
sqlConnection.Open()
sqlCommand.CommandText = sqlQuery
sqlCommand.ExecuteNonQuery()
sqlConnection.Close()
Catch ex As Exception
MsgBox("Invalid ID or Password. Please try again.")
End Try
编辑1:
在这下面的代码为什么我需要使用GetInt16(0)。为什么16和为什么0在参数中。是什么)GetInt32等(),GetInt16()和GetString(区别所有的
DbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
int id= reader.GetInt16(0);
}
reader.Close();
先生,您能否向我提供DataReader示例代码 – 2011-04-24 05:57:48
@Failed_Noob - 先生,您如何遵循我提供的链接,阅读文档(有示例),并自己学习? – Oded 2011-04-24 05:58:48
对不起,没有看到链接 – 2011-04-24 06:04:33