Hello

Below is my entire code of a mobile application. The 4th form with the ID "bookDetails" is supposed to be used to retrieve data from a database called butternut3.mbd. I am currently stuck on writing a code in the script part, for a user to search and view details of a book from an access database, the user enters a book title in the textbox to view details of that particular book. :-/ Please help.
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage"
Language="c#" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server" language="C#">
    private void Command1_Click(object sender, System.EventArgs e)
    {
    }

    void Page_Load(Object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Create a connection string
            string strConn =
            "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" +
            (string)Server.MapPath("butternut3.mdb");
            //Create the SQL Statement
            string strSQL = "SELECT * from books";
            //Create a Connection object
            OleDbConnection Conn = new OleDbConnection(strConn);
            //Create a command object using the connection object
            OleDbCommand Cmd = new OleDbCommand(strSQL,Conn);
            //Open the DB connection
            Conn.Open();
            //Data bind the DataReader object
            //into the List control
            objLst.DataSource =
            Cmd.ExecuteReader(CommandBehavior.CloseConnection);
            objLst.DataBind();
            }

    }

</script>

<mobile:Form id="Form1" runat="server">
    <mobile:Image runat="server"
        ImageURL="image1.jpg"
        NavigateURL="#menu">
    </mobile:Image>
    <mobile:Link runat="server"
        navigateurl="#menu">
        Click here or the image to continue
    </mobile:Link>
    Butternut Books brings you the very best in reading in all categoies of books. 
    This handy mobile site lets you browse our catalogue and order any book, from 
    the convenience of your mobile.
</mobile:Form>
<mobile:Form id="menu" runat="server">
    <mobile:Label id="Label1" runat="server">
    Butternut Books Menu
    </mobile:Label>
    <mobile:Link runat="server" NavigateURL="#bookList">
    View the book list
    </mobile:Link>
    <mobile:Link runat="server" NavigateURL="#bookDetails">
    View details of one book
    </mobile:Link>
    <mobile:Link runat="server" NavigateURL="">
    Order a book
    </mobile:Link>
    <mobile:Link runat="server" NavigateURL="#Form1">
    Back to homepage
    </mobile:Link>
    <mobile:Image runat="server"
        ImageURL="image1.jpg">
    </mobile:Image>
</mobile:Form>

<mobile:Form id="bookList" runat="server" >

    <mobile:Label runat="server" text= "Butternut Book List" />
    <mobile:ObjectList id="objLst" runat="server" AutoGenerateFields="false">
     <Field Title="Book Title" dataField="book_title"/>
    <Field Title="Author" DataField="book_author" /> 
    <Field Title="Book Cover" DataField="book_cover"/>
</mobile:ObjectList>
   <mobile:Link runat="server" NavigateURL="#Form1">
    Back to homepage
    </mobile:Link>
</mobile:Form>

<mobile:Form id="bookDetails" runat="server">
    <mobile:Label runat="server" text= "Butternut Book List" />
    <mobile:Label runat="server">Please enter the name of the book:</mobile:Label>
    <mobile:TextBox runat="server" id="txtName" />
    <mobile:Command id="Command1" runat="server" OnClick="Command1_Click">
Display</mobile:Command>
<mobile:ObjectList id="objLst1" runat="server" AutoGenerateFields="true"/>
<mobile:Link runat="server" NavigateURL="#Form1">
    Back to homepage
    </mobile:Link>
</mobile:Form>

This should be posted under ASP.Net

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.