Prepare for your Next Interview
This is a discussion on Asp.net 2.0 page loaded from MS Access within the ASP.NET forums, part of the Web Development category; Hi, I'm new at this .net programming world but trying to learn. I am trying to create a webpage that loads it's information from an MS Access database ...
|
|||
|
Hi, I'm new at this .net programming world but trying to learn. I am trying to create a webpage that loads it's information from an MS Access database in Microsoft Visual Web Developer 2005 Express. It work in the testing inviroment, but when I upload it to my hosting server it doesn't work. Do I have to write some kind of connection string to the database and display code to display the contents of the database. If so where should I put the code. If someone could give me some info or examples it would be good. Thanks greatly appreciate your help.
|
| Sponsored Links |
|
|||
|
Re: Asp.net 2.0 page loaded from MS Access
Use this code my dear <%@ page language=vb debug=true %> <%@ import namespace="system.data" %> <%@ import namespace="system.data.oledb" %> <script runat=server> sub page_load(byval sender as object, byval e as eventargs) if not ispostback then dim dbconn as oledbconnection dim dbcommand as oledbdataadapter dim dspagedata as new dataset 'dbconn = new oledbconnection( _ ' "provider=microsoft.jet.oledb.4.0;" _ ' & "data source=" _ ' & server.mappath("employeedatabase.mdb;")) 'dbconn = new oledbconnection( _ ' "provider=microsoft.jet.oledb.4.0;" _ ' & "data source=" _ ' & "c:\inetpub\wwwroot\employeedatabase.mdb;") dbconn = new oledbconnection( _ "provider=microsoft.jet.oledb.4.0;" _ & "data source=" _ & mappath("employeedatabase.mdb;")) dbcommand = new oledbdataadapter _ ("select lastname & ', ' & firstname " _ & "as empname, id " _ & "from employee " _ & "order by lastname, firstname", dbconn) dbcommand.fill(dspagedata, _ "employee") ddlemps.datasource = _ dspagedata.tables("employee").defaultview ddlemps.databind() end if end sub </script> <html> <head> <title>connecting to an access database</title> </head> <body leftmargin="40"> <form runat="server"> <br><br> <asp:dropdownlist id="ddlemps" datatextfield="empname" datavaluefield="id" runat="server" /> </form> </body> </html>
|
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Method to identify the loaded web page | Geek_Guest | QTP | 1 | 12-21-2007 07:16 PM |
| Java Applet not loaded in Active Screen | amni7303 | QTP | 0 | 11-14-2007 12:39 AM |
| Access Boss is a great access management and time control utility that allows you to | JobHelper | Geeks Lounge | 0 | 07-22-2007 05:40 AM |
| I wish to add total number of records loaded | N SRIRAM K | Data Warehousing | 0 | 06-23-2007 08:57 AM |
| Winrunner is taking the entire web page as a single page | Sridevi.P | WinRunner | 0 | 06-05-2007 11:26 PM |