Welcome to Dream.In.Code
Become an Expert!

Join 150,053 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,735 people online right now. Registration is fast and FREE... Join Now!




connecting access database to asp.net

 
Reply to this topicStart new topic

connecting access database to asp.net

prads
21 Feb, 2008 - 12:53 AM
Post #1

D.I.C Head
**

Joined: 22 Oct, 2007
Posts: 111


My Contributions
Hello,
I am doing a project in which i have to connect a given access database to a created asp.net page(default.aspx).
The asp page should ask for the following inputs from the user and connect the "Fruit" entry to the given access database and also validate it by displaying the quantity and price of the selected fruit. Here's what the asp page asks for: Name, Address, zipcode, Email id, Date and Fruit. Here's the code i have written but havent yet done the database connectivity part. After clicking the submit button it should compare the fruit entry with the database available fruits and display the quantity and price of the selected fruit or else as "Not Available in the database". Somebody kindly explain. Remember I don't have to create a database with rows and columns but have an access database called fruits.mdb given.

CODE


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
        &nbsp; &nbsp;
        <asp:TextBox ID="TextBox1" runat="server" ForeColor="Black"></asp:TextBox>
        &nbsp;
        <asp:Label ID="Label2" runat="server" ForeColor="Red"></asp:Label>
    </div>
    
    <div>
        <asp:Label ID="Label3" runat="server" Text="Address"></asp:Label>&nbsp;
        <asp:TextBox ID="TextBox2" runat="server" Height="86px" Width="145px" ForeColor="#C0C000"></asp:TextBox>&nbsp;&nbsp;&nbsp;
        <asp:Label ID="Label4" runat="server" ForeColor="Red"></asp:Label>
         </div>
        
    <div>
        <asp:Label ID="Label5" runat="server" Text="Zipcode"></asp:Label>&nbsp;
        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
        &nbsp;
        <asp:Label ID="Label6" runat="server" ForeColor="Red"></asp:Label>
        </div>
        
        <div>
        <asp:Label ID="Label7" runat="server" Text="Email"></asp:Label>
            &nbsp; &nbsp;&nbsp;
        <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
            &nbsp;
            <asp:Label ID="Label8" runat="server" ForeColor="Red"></asp:Label>
        </div>
        
         <div>
        <asp:Label ID="Label11" runat="server" Text="Fruit"></asp:Label>
             &nbsp; &nbsp; &nbsp;
             <asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
             &nbsp;
             <asp:Label ID="Label12" runat="server" ForeColor="Red"></asp:Label>
        </div>
        
        <div>
        <asp:Label ID="Label9" runat="server" Text="Date"></asp:Label>
             &nbsp; &nbsp; &nbsp;
             <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
             &nbsp;
             <asp:Label ID="Label10" runat="server" ForeColor="Red"></asp:Label>
        </div>
        
        
         </form>
</body>
</html>


Somebody pls explain it step by step because im new to this webpage designing and have limited understanding.
Thanks,
prads
User is offlineProfile CardPM
+Quote Post

dilipv
RE: Connecting Access Database To Asp.net
26 Feb, 2008 - 02:47 AM
Post #2

New D.I.C Head
*

Joined: 9 Feb, 2008
Posts: 9

hi prads,

i saw your quote.there are many things to be taken into consideration, so i thought of refering you the site where all information regarding the connection of database is given. please check out the following url

http://msdn2.microsoft.com/en-us/library/ms247233.aspx

or

Check out the following code
CODE

<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>
<html>
<script language="VB" runat="server">
Sub GetAuthors_Click(Sender As Object, E As EventArgs)
Dim DS As DataSet
Dim MyConnection As ADOConnection
Dim MyCommand As ADODataSetCommand
Dim SelectCommand As String = "SELECT * FROM Authors"
MyConnection = New ADOConnection("dsn=pub2")
MyCommand = New ADODataSetCommand(SelectCommand, MyConnection)
DS = new DataSet()
MyCommand.FillDataSet(DS, "Authors")
MyDataGrid.DataSource=DS.Tables("Authors").DefaultView
MyDataGrid.DataBind()
End Sub
</script>


Hope this thing will obviously help you out.

Thank you
Jitesh
Programmer
Sharepoint Consulting
User is offlineProfile CardPM
+Quote Post

bhandari
RE: Connecting Access Database To Asp.net
26 Feb, 2008 - 02:52 AM
Post #3

D.I.C Addict
Group Icon

Joined: 31 Jan, 2008
Posts: 747


Dream Kudos: 900
My Contributions
jitesh, always put your code in code tags as in the question. That makes it more readable.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:21PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month