neriahfred 0 Newbie Poster

I'm developing a mobile website using vb.net but having set my tools right as I read somewhere, I've having an object reference...null error from the sqladapter line. I'm trying to authenticate by checking the db for username and password and granting or denying access asthe case maybe, here's my code, what am I not doing right? Pls help
Thanx
NB: I;m using visual studio 2005

Imports System.Data 
Imports System.Data.SqlClient 
Imports DataSet1TableAdapters.authenticateTableAdapter 
Imports System.Web.Security 
Imports System.Web.Mobile 
Imports  System.Data.SqlClient.SqlParameterCollection 
 
 
 
 
Partial Class login 
    Inherits System.Web.UI.MobileControls.MobilePage 
    Dim ds As New DataSet1 
    Dim users As New DataSet1TableAdapters.authenticateTableAdapter 
    Dim SqlDataAdapter1 As New SqlDataAdapter 
 
    ''Public ReadOnly Property Parameters() As SqlParameterCollection 
    ''    Get 
 
    ''    End Get 
    ''End Property 
    ' ''Usage 
 
    'Dim instance As New SqlCommand 
    'Dim value As SqlParameterCollection 
    ''value = instance.Parameters 
 
 
    'Private Sub ConnectToSQL() 
    '    Dim con As New SqlConnection 
    '    Dim cmd As New SqlCommand 
    '    Try 
    '        con.ConnectionString = "Data Source= NERIAH-PC\SQLEXPRESS;Initial Catalog=asset;Persist Security Info=True;User ID=NERIAH-PC\Ebby;Password=waziri" 
    '        con.Open() 
    '        Label3.Text = "sucess" 
    '    Catch ex As Exception 
    '        Label3.Text = ("Error while connecting to SQL Server." & ex.Message) 
    '    Finally 
    '        con.Close() 'Whether there is error or not. Close the connection. 
    '    End Try 
    'End Sub 
    Protected Sub cmdLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdLogin.Click 
 
 
 
        SqlDataAdapter1.SelectCommand.Parameters("@u_name").Value = txtUsername.Text 
        SqlDataAdapter1.SelectCommand.Parameters("@p_word").Value = txtPassword.Text 
        Try 
            SqlDataAdapter1.Fill(ds, "Table1") 
            If ds.Tables("Table1").Rows.Count = 0 Then 
                ActiveForm = frmHome 
                Label2.Text = "Sorry, either your password or username was incorrect. Please enter your details again." 
            Else 
                Dim user_id As Integer = ds.Tables("authenticate").Rows(0).Item("user_id") 
                MobileFormsAuthentication.RedirectFromLoginPage(user_id, False) 
            End If 
        Catch 
            'ActiveForm = loginForm2 
            Label2.Text = "Sorry, the server is temporarily unavailable. Please try again." 
        End Try 
 
        'If ((txtUsername.Text = "Admin") And (txtPassword.Text = "admin")) Then 
        'ActiveForm = frmHome 
 
        'For Each dr As DataRow In users.GetDataBy(txtUsername.Text, txtPassword.Text) 
        '    If (dr.Item("u_name").ToString = txtUsername.Text) & (dr.Item("p_word").ToString = txtPassword.Text) Then 
        '        ActiveForm = frmHome 
        '    End If 
        'Next 
 
 
        'lblUserwelcome.Text = txtUsername.Text 
        ' Else 
        ' lblError.Visible = True 
        'End If 
    End Sub 
 
End Class

Was This Post Helpful? 0  Report
 Back to top
  MultiQuote
  Reply
  Edit
 
--------------------------------------------------------------------------------
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.