Asp.net 2.0 page loaded from MS Access
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.
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>