Mark wrote:
> Hi,
>
> I'm fairly new to .NET and having problems getting an ASP.NET page
> working on my web host.
>
> The page works fine on my PC running against localhost. I have a MySQL
> database and a simple C# app with an odbcConnection object,
> odbcDataAdapter and a datasetCustomers object placed on the form.
>
> On page load, I fill the datasetCustomers from the "Customers" table
> retrieved via the odbcDataAdapter and then bind this to a DataGrid on
> the form - this works perfectly on localhost and the web-page displays
> the contents of the Customers table.
>
> I've got the same database on the webhost and I'm fairly sure it
> should all work, but I get the following error: -
>
> Compiler Error Message: CS0234: The type or namespace name
> 'dsCustomers' does not exist in the class or namespace
> 'BoundMySQLTest' (are you missing an assembly reference?)
>
> Source Error:
> Line 24: protected System.Data.Odbc.OdbcCommand odbcInsertCommand1;
> Line 25: protected System.Web.UI.WebControls.DataGrid DataGrid1;
> Line 26: protected BoundMySQLTest.dsCustomers dsCustomers1;
> Line 27:
> Line 28: private void Page_Load(object sender, System.EventArgs e)
>
> It states the error is with line 26.
What is "dsCustomers" exactly?
The declaration seems to specify that it's a class in the BoundMySQLTest namespace,
but a name like this I personally would use to specify a variable pointing to
a DataSet that contained "customer" details.
>
> The only change I've made before uploading it is to change the top
> line in Webform1.aspx from: -
>
> <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
> AutoEventWireup="false" Inherits="BoundMySQLTest.WebForm1"%>
>
> to: -
>
> <%@ Page language="c#" Src="WebForm1.aspx.cs" AutoEventWireup="false"
> Inherits="BoundMySQLTest.WebForm1"%>
>
> For some reason, none of my projects work on my webhost with the
> "Codebehind" line - I always have to change it to Src.
>
The "codebehind" is used by VS.Net and you run it (locally) by compiling
the codebehind into a dll that is then used.
When you upload all sourcefiles (aspx.cs) and no dll's (see bin directory)
then it needs to be changed to "src" so that the system can again find the
codebehind files and compile them.
Within VS.Net there is a "Copy Project" function to send all files needed
to a webserver. This will include the compiled dll's and exclude the .cs
(as they are not needed). Make sure that all support files (like xml files)
that you want to have at that webserver have a "build action" of "content"
instead of "none" (see file properties).
> Other than this, the project is identical - works on localhost, but
> not on my webserver.
>
> I've had a good read around on here - read a few articles about
> manually adding references in the Global.asax, but I have to admit I'm
> still fairly confused.
>
> Any help would be greatly appreciated,
>
> Mark.
|