Sub btnLogin_Click(sender As Object, e As EventArgs)
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("database/mydatabase.mdb")&";Jet OLEDB:Database Password=;"
objConn.ConnectionString = strConnString
objConn.Open()
Dim intNumRows As Integer
strSQL = "SELECT COUNT(*) FROM member WHERE Username = '"& Me.txtUsername.Text &"' AND [Password] = '"& Me.txtPassword.Text &"' "
objCmd = New OleDbCommand(strSQL, objConn)
intNumRows = objCmd.ExecuteScalar()
IF intNumRows > 0 Then
Session("strUser") = Me.txtUsername.Text
Response.Redirect("Page1.aspx")
Else
Me.pnlLogin.Visible = False
Me.lblStatus.Visible = True
Me.lblStatus.Text = "Username/Password is wrong."
End IF
objConn.Close()
objConn = Nothing
End Sub
Dim dt As New DataTable
Dim conn As OleDbConnection
Dim strConn As String = "Provider=SQLOLEDB;Data Source=nameserver;Initial Catalog=myDB; User ID=username;Password=password"
conn = New OleDbConnection(strConn)
Try
conn.Open()
Dim dataAdepter As OleDbDataAdapter = New OleDbDataAdapter(sqlCommand, conn)
Dim ds As New DataSet
dataAdepter.Fill(ds)
If ds.Tables.Count > 0 Then dt = ds.Tables(0)
Catch ex As Exception
If conn.State = ConnectionState.Closed Then/server.aspx?target=_parent")
Else
Throw New Exception(ex.Message)
End If
End Try
conn.Close()
Return dt