Pocket PC development with MS SQL
I got an error keep on prompting telling me NullReferenceException when i run the pocketpc emulator to test my development. Can anyone tell me what's the problem. I will attach my code below as reference. Thanks
rivate Sub cmdConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnect.Click
Dim frmSelector As New frmSelector
Dim frmLoginMgmt As New frmLoginMgmt
Dim conn As New SqlConnection
Try
conn.ConnectionString = "server=celeron; uid=James; password=something; database=LPL"
conn.Open()
Dim sql As SqlCommand
sql.CommandText = "SELECT * FROM tbllogin WHERE username='txtusername.Text' AND password='txtpwd.text';"
If sql.CommandText = True Then
'If txtusername.Text = "admin" And txtpwd.Text = "admin" Then
MessageBox.Show("Connection Established")
frmSelector.Show()
Else
MessageBox.Show("Invalid Login Name or Password")
End If
Catch sqlex As SqlException
Dim sqlError As SqlError
For Each sqlError In sqlex.Errors
MessageBox.Show(sqlError.Message)
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
If conn.State <> ConnectionState.Closed Then
conn.Close()
End If
End Try
End Sub
End Class
|