D
Don
I'm having a problem connecting to a MSSQL server database from an
ASP.NET page. Here's the connection code I'm using:
<%@ Page Language="c#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
void Page_Load()
{
string connectionStr =
"server=DBServer;uid=sa;pwd=Password;database=DB";
string queryStr = "SELECT * FROM Calendar";
SqlConnection connectObj = new
SqlConnection(connectionStr);
SqlCommand commandObj = new
SqlCommand(queryStr,connectObj);
SqlDataReader readerObj;
connectObj.Open();
readerObj=commandObj.ExecuteReader();
dataGridControl.DataSource = readerObj;
dataGridControl.DataBind();
}
</script>
<html>
<head>
<title>Using a DataReader</title>
</head>
<body>
<h2>Using a DataReader
</h2>
<aspataGrid id="dataGridControl" runat="server"></aspataGrid>
</body>
</html>
This page works fine when I test it locally (using Cassini), and the
connection string works fine on my development server within a Classic
ASP page, but once I upload it to my development server it returns a
"Server Error in '/' Application."
Has anyone come across a similar problem?
Thanks.
ASP.NET page. Here's the connection code I'm using:
<%@ Page Language="c#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
void Page_Load()
{
string connectionStr =
"server=DBServer;uid=sa;pwd=Password;database=DB";
string queryStr = "SELECT * FROM Calendar";
SqlConnection connectObj = new
SqlConnection(connectionStr);
SqlCommand commandObj = new
SqlCommand(queryStr,connectObj);
SqlDataReader readerObj;
connectObj.Open();
readerObj=commandObj.ExecuteReader();
dataGridControl.DataSource = readerObj;
dataGridControl.DataBind();
}
</script>
<html>
<head>
<title>Using a DataReader</title>
</head>
<body>
<h2>Using a DataReader
</h2>
<aspataGrid id="dataGridControl" runat="server"></aspataGrid>
</body>
</html>
This page works fine when I test it locally (using Cassini), and the
connection string works fine on my development server within a Classic
ASP page, but once I upload it to my development server it returns a
"Server Error in '/' Application."
Has anyone come across a similar problem?
Thanks.