selecting in with ms access database

I want to select some data in my table and I use this code :

Public Class frmLogin
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
            Dim t As New DataTable
    Dim adapter As OleDbDataAdapter = New OleDbDataAdapter()
    Dim cmd As OleDbCommand
    Dim reader As OleDbDataReader = Nothing
    Dim tuser As String = txtUsername.Text

    Dim sql As String = "SELECT * FROM dosen WHERE nip=tuser"
        cmd = New OleDbCommand(sql, conn)
        reader = cmd.ExecuteReader()

        While reader.Read
            MessageBox.Show(reader.GetString(0).ToString & _
                            vbTab & vbTab & reader.GetString(1).ToString)
        End While
        If reader IsNot Nothing Then reader.Close()
    End Try

End Sub

But there is an error in reader = cmd.ExecuteReader() line. Anyone can help me?


Correct the mistakes. The code should be

Dim reader As OleDbDataReader ' no need for nothing
Dim adapter As New OleDbDataAdapter()
Dim sql As String = "SELECT * FROM dosen WHERE nip='" & tuser & "'"

tuser is a variable, not the content

Need Your Help

ADB, Wifi and Eclipse: how I can configure?

android eclipse wifi adb ddms

Recently I see that is possible to debug app development by use WIFI instead of USB debug method. I make a search and I found an app called abdWireless but I have a problem.

Setting title on a styled control

.net wpf popup styles

I have created a WPF popup style and using it in many places in the application.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.