Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database path won't work!!!

Status
Not open for further replies.

WestView

Technical User
Jan 7, 2003
67
US
Hello All,

This is driving me CRAZY! All I’m trying to do is change the database path from this:

Code:
 	string connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ Server.MapPath("access.mdb") +";";
	string sql = "select * from events";

To something like this:

Code:
 	string connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data SourceProvider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\dir1\dir2\dir3\database\access.mdb;	
string sql = "select * from events";

I’ve tried a hundred different combinations, and nothing works.

The entire code for the page is this:

Code:
 <?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Xml" %>
<script runat="server">

DataSet ds = new DataSet();
protected void Page_Load(Object Src, EventArgs E)
{
	string connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ Server.MapPath("access.mdb") +";";
	string sql = "select * from events";
	
	OleDbDataAdapter da = new OleDbDataAdapter(sql, connectionstring);	
	da.Fill(ds, "events");
	
}

protected void eventscalendar_DayRender(Object Src, DayRenderEventArgs E)
{
	StringBuilder strEvents = new StringBuilder();
	strEvents.Append("<span style=\"font-size:80%\">");
	
	foreach (DataRow row in ds.Tables["events"].Rows)
	{
		DateTime eventdate = (DateTime)row["eventdate"];
		if (eventdate.Equals(E.Day.Date))
			strEvents.Append("<br />" + row["eventtext"]);
	}
	
	strEvents.Append("</span>");
	E.Cell.Controls.Add(new LiteralControl(strEvents.ToString()));
}
</script>
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>Event Calendar</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<form runat="server">
	<asp:calendar DayStyle-HorizontalAlign="right" ID="eventcalendar" runat="server" ShowGridLines="true" OnDayRender="eventscalendar_DayRender"></asp:calendar>
</form>

</body>
</html>

Must I do something with the “Global.asax” ?

Any/all help would be greatly appreciated!!!

I'm using DW-MX 2004 on a asp.net server

- tom
 
any errors?
does the IUSR_machine have the access to that folder? it must be part of (virutal folder) the site...

:--------------------------------------------------------------------------:
fugitive.gif

ok,ok...I did shoot the deputy but he told me he was the sheriff!
:--------------------------------------------------------------------------:
 
Hi Lebisol,

Thanks for your reply. All I get for error messages is: "Server Error in '/' Application.
Runtime Error"

Thanks again,

- Tom
 
try something like:
Code:
CONN_STRING = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/DB/some.mdb") & ";  User ID=Admin; Password=admin;"
confrim the diffenrece between
1) Server.MapPath ("/VIRTUAL FOLDER/myDB.mdb")
vs.
2) Server.MapPath ("myDB.mdb")
second example assumes that your DB sits int he root of your site and not in any subfolder...

Again, if you point your DB source directly as full path C:\dir\dir... make sure that those directories are deifined as a part of your site and that webuser have access to that final folder.
Don't much about XML so I can not help with that part!
All the best!


:--------------------------------------------------------------------------:
fugitive.gif

ok,ok...I did shoot the deputy but he told me he was the sheriff!
:--------------------------------------------------------------------------:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top