Possible Duplicate:
Checking for an SQL result in VB.NET
I have login form which is redirect user for their levels but before to that if there is no any user on the data table I would like to redirect to create admin form. I have all the forms but I didn't manage to redirect them because I don't know how to create statement. Could you please help me about solution.
Dim con As SqlCeConnection
Dim command As SqlCeCommand
con = New SqlCeConnection("Persist Security Info=False;Data Source=.\database.sdf;Password=26091974-emre;File Mode=shared read")
con.Open()
command = New SqlCeCommand("select * from users where Name=? and Password=?", con)
Dim param1, param2 As SqlCeParameter
param1 = New SqlCeParameter("Name", uname.Text)
param2 = New SqlCeParameter("Password", pwd.Text)
command.Parameters.Add(param1)
command.Parameters.Add(param2)
Dim reader As SqlCeDataReader = command.ExecuteReader
If (reader.Read = True) Then
role = reader.GetString(1)
Else
MsgBox("Invalid Login")
End If
I have this code is working. What to write for
Private Sub frmlogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub