Hi,
Till now we had done the Programming using SQL Server and XML as databases. Truely speaking, I never thought of using MS Access till two days back when I got a mail asking for this. So here is something with Access. In this Example the authetication unit is there from Access Database.
Just make a simple Table having three Coloumns UserName,Password and Info .Here you will asking user for username and password and if authenticated provide him with the info field.
Check out the Code
Source Code:
//AccessData.aspx
<mobile:Form runat="server" ID="Form1">
<mobile:Label id="WelcomeMessage" runat="server">
</mobile:Label>
</mobile:Form>
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" Language="C#"Debug="true" %>
<%@ Register TagPrefix="mobile"Namespace="System.Web.UI.MobileControls
"Assembly="System.Web.Mobile" %
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server" language="C#">
public String str;
public string strAccessConn ="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=E:Shivani/Shivani.mdb ";
DataSet myDataSet = new DataSet();
int RowCount;
public void Check_Login(Object sender, EventArgs e)
{
if(Page.IsValid)
{
OleDbConnection myAccessConn = new OleDbConnection(strAccessConn);
OleDbCommand myAccessCommand = new OleDbCommand("select info from mytable
where UserName ='"+Login.Text +"'and Password
='"+Password.Text+"'",myAccessConn);
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(myAccessCommand);
myAccessConn.Open();
try
{
myDataAdapter.Fill(myDataSet,"mytable");
}
finally
{
myAccessConn.Close();
}
RowCount = myDataSet.Tables["mytable"].Rows.Count ;
DataRowCollection dra = myDataSet.Tables["mytable"].Rows ;
foreach (DataRow dr in dra)
{
str = dr[0].ToString();
}
if (RowCount == 0)
{
ActiveForm = Form3;
}
else
{
ConfirmLogin.Text = "your current Balance is $"+str;
ActiveForm =Form2;
}
}
</script>
<mobile:Form id = "Form1" runat="server">
<mobile:Label runat="server" ID="Label1">Login</mobile:Label>
<mobile:TextBox runat="server" id="Login" />
<mobile:Label runat="server" ID="Label2">Password</mobile:Label>
<mobile:TextBox runat="server" id="Password" Password="True"/>
<mobile:Command runat="server" OnClick="Check_Login" Text="Go!"
ID="Command1"/>
</mobile:Form>
<mobile:Form runat="server" id="Form2">
<mobile:Label id ="ConfirmLogin" runat="server" />
</mobile:Form>
<mobile:Form runat="server" id="Form3">
<mobile:Label id ="Fails" runat="server" >Authentication Failed </mobile:Label>
<mobile:Link runat="server" NavigateURL="#Form1" ID="Link1">Try
Again</mobile:Link>
</mobile:Form>
Here you can access Coloumn,get the Count of Rows,Coloumns ,No of Tables in a DataBase and many more things you can do.Let me explore this name space some More and very soon let make a design play with this also. Till then Have Fun.