Hello,
I new on developing with ASP.NET and i wrote some lines of code. This
works fine when all the code is in one page, but when i split it up into and
ASPX file and make an DLL using a namespace i get an error :
============= ERROR
Compiler Error Message: CS0234: The type or namespace name 'SQLGetPhones'
does not exist in the class or namespace 'WallpaperEditorDataManager' (are
you missing an assembly reference?)
Source Error:
Line 12: public void fnFillFormData()
Line 13: {
Line 14: PhoneList.DataSource =
WallpaperEditorDataManager.SQLGetPhones("Select * from phones").DefaultView;
Line 15: PhoneList.DataBind();
Line 16:
Source File: E:\wwwroot\aspx\test1.aspx Line: 14
=========== / ERROR
I used the following command to compile the DLL:
csc /t:library /r:System.dll /r:System.Data.dll
/out:bin/WallpaperEditorDataManager.dll test1.cs
Could someone explain me what is going wrong? I also,below, added the lines
of code i use.
Please help me with my first steps.
Bart de Vries
=========== SOURCE test1.cs
using System;
using System.Data;
using System.Data.SqlClient;
namespace WallpaperEditorDataManager
{
public class PhonesDB
{
public DataTable SQLGetPhones(string strQuery)
{
SqlConnection myConnection = new SqlConnection("User
ID=xxxx;password=xxxx;Initial Catalog=xxxx;Data Source=localhost;");
SqlDataAdapter myAdapter = new SqlDataAdapter(strQuery,
myConnection);
DataSet phones = new DataSet();
myAdapter.Fill(phones,"phones");
return phones.Tables[0];
}
}
}
========== / SOURCE test1.cs
========== SOURCE test1.aspx
<%@ Page Language="c#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="WallpaperEditorDataManager" %>
<script runat="server">
void Page_Load(Object s, EventArgs e)
{
fnFillFormData();
}
public void fnFillFormData()
{
PhoneList.DataSource =
WallpaperEditorDataManager.SQLGetPhones("Select * from phones").DefaultView;
PhoneList.DataBind();
ddlPhoneBrand.DataSource =
WallpaperEditorDataManager.SQLGetPhones("Select DISTINCT phone_brand from
phones").DefaultView;
ddlPhoneBrand.DataTextField = "phone_brand";
ddlPhoneBrand.DataValueField = "phone_brand";
ddlPhoneBrand.DataBind();
}
</script>
blah blah blah, some more lines containing the HTML and
ASP data elements
========== / SOURCE test1.aspx 4 1570
Or should i use codeBehind instead?
"Bart de Vries" <ma**@notpossible.nl> schreef in bericht
news:40***********************@news.xs4all.nl... Hello,
I new on developing with ASP.NET and i wrote some lines of code. This works fine when all the code is in one page, but when i split it up into
and ASPX file and make an DLL using a namespace i get an error :
============= ERROR Compiler Error Message: CS0234: The type or namespace name 'SQLGetPhones' does not exist in the class or namespace 'WallpaperEditorDataManager' (are you missing an assembly reference?)
Source Error:
Line 12: public void fnFillFormData() Line 13: { Line 14: PhoneList.DataSource = WallpaperEditorDataManager.SQLGetPhones("Select * from
phones").DefaultView; Line 15: PhoneList.DataBind(); Line 16:
Source File: E:\wwwroot\aspx\test1.aspx Line: 14 =========== / ERROR
I used the following command to compile the DLL:
csc /t:library /r:System.dll /r:System.Data.dll /out:bin/WallpaperEditorDataManager.dll test1.cs
Could someone explain me what is going wrong? I also,below, added the
lines of code i use.
Please help me with my first steps.
Bart de Vries =========== SOURCE test1.cs using System; using System.Data; using System.Data.SqlClient;
namespace WallpaperEditorDataManager { public class PhonesDB { public DataTable SQLGetPhones(string strQuery) {
SqlConnection myConnection = new SqlConnection("User ID=xxxx;password=xxxx;Initial Catalog=xxxx;Data Source=localhost;"); SqlDataAdapter myAdapter = new SqlDataAdapter(strQuery, myConnection); DataSet phones = new DataSet(); myAdapter.Fill(phones,"phones");
return phones.Tables[0]; } } }
========== / SOURCE test1.cs
========== SOURCE test1.aspx
<%@ Page Language="c#" Debug="true" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="WallpaperEditorDataManager" %> <script runat="server">
void Page_Load(Object s, EventArgs e) { fnFillFormData(); }
public void fnFillFormData() { PhoneList.DataSource = WallpaperEditorDataManager.SQLGetPhones("Select * from
phones").DefaultView; PhoneList.DataBind();
ddlPhoneBrand.DataSource = WallpaperEditorDataManager.SQLGetPhones("Select DISTINCT phone_brand from phones").DefaultView; ddlPhoneBrand.DataTextField = "phone_brand"; ddlPhoneBrand.DataValueField = "phone_brand"; ddlPhoneBrand.DataBind(); }
</script>
blah blah blah, some more lines containing the HTML and ASP data elements
========== / SOURCE test1.aspx
Hi, Or should i use codeBehind instead?
Yes, you should
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
is there a specific reason for using Codebehind instead of the other way?
And could you also still tell me why the first option is going wrong?
Bart de Vries
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schreef in bericht news:uu****************@TK2MSFTNGP09.phx.gbl... Hi,
Or should i use codeBehind instead?
Yes, you should
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation
Bart,
You are trying to call an instance method (SQLGetPhones), which belongs
to the class PhonesDB, directly from the namespace. That is not possible.
two solutions:
a) first an instance of PhonesDb, then call the method
PhonesDB myDB = new PhonesDB();
PhoneList.DataSource = myDB.SQLGetPhones(...);
b) make it a static method and call that
add "static" to the declaration:
public static DataTable SQLGetPhones(string strQuery)
PhoneList.DataSource = PhonesDB.SQLGetPhones(...)
Hans Kesting
"Bart de Vries" <ma**@notpossible.nl> wrote in message news:40***********************@news.xs4all.nl... Hello,
I new on developing with ASP.NET and i wrote some lines of code. This works fine when all the code is in one page, but when i split it up into and ASPX file and make an DLL using a namespace i get an error :
============= ERROR Compiler Error Message: CS0234: The type or namespace name 'SQLGetPhones' does not exist in the class or namespace 'WallpaperEditorDataManager' (are you missing an assembly reference?)
Source Error:
Line 12: public void fnFillFormData() Line 13: { Line 14: PhoneList.DataSource = WallpaperEditorDataManager.SQLGetPhones("Select * from phones").DefaultView; Line 15: PhoneList.DataBind(); Line 16:
Source File: E:\wwwroot\aspx\test1.aspx Line: 14 =========== / ERROR
I used the following command to compile the DLL:
csc /t:library /r:System.dll /r:System.Data.dll /out:bin/WallpaperEditorDataManager.dll test1.cs
Could someone explain me what is going wrong? I also,below, added the lines of code i use.
Please help me with my first steps.
Bart de Vries =========== SOURCE test1.cs using System; using System.Data; using System.Data.SqlClient;
namespace WallpaperEditorDataManager { public class PhonesDB { public DataTable SQLGetPhones(string strQuery) {
SqlConnection myConnection = new SqlConnection("User ID=xxxx;password=xxxx;Initial Catalog=xxxx;Data Source=localhost;"); SqlDataAdapter myAdapter = new SqlDataAdapter(strQuery, myConnection); DataSet phones = new DataSet(); myAdapter.Fill(phones,"phones");
return phones.Tables[0]; } } }
========== / SOURCE test1.cs
========== SOURCE test1.aspx
<%@ Page Language="c#" Debug="true" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="WallpaperEditorDataManager" %> <script runat="server">
void Page_Load(Object s, EventArgs e) { fnFillFormData(); }
public void fnFillFormData() { PhoneList.DataSource = WallpaperEditorDataManager.SQLGetPhones("Select * from phones").DefaultView; PhoneList.DataBind();
ddlPhoneBrand.DataSource = WallpaperEditorDataManager.SQLGetPhones("Select DISTINCT phone_brand from phones").DefaultView; ddlPhoneBrand.DataTextField = "phone_brand"; ddlPhoneBrand.DataValueField = "phone_brand"; ddlPhoneBrand.DataBind(); }
</script>
blah blah blah, some more lines containing the HTML and ASP data elements
========== / SOURCE test1.aspx
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Wayno |
last post by:
My php logs are coming up empty. I have done all I can think of, and
all that made sense to me. Can someone take a look at my php.ini
please and tell me what you think may be the problem.
I...
|
by: Enos Meroka |
last post by:
Hallo,
I am a student doing my project in the university.. I have been trying
to compile the program using HP -UX aCC compiler, however I keep on
getting the following errors.
...
|
by: Peter Frost |
last post by:
Please help
I don't know if this is possible but what I would really like to do is
to use On Error Goto to capture the code that is being executed when
an error occurs.
Any help would be much...
|
by: JTrigger |
last post by:
When I compile my project using the IDE on a development machine it works
just fine. When I compile it on the server using csc.exe, I get the
following error when I try to bring it up in the web...
|
by: Kevin R. |
last post by:
I have been ignoring this problem for a few weeks now, but it's becoming
a bit annoying not to mention unproductive. Here it goes:
I compile my project with no errors. Then after I debug/run it,...
|
by: james margey |
last post by:
Hi to all,
I have spent 3 days at this error and i have two days to go for a
deadline, and i am about to go off my nut, the reason being: Microsoft
dont seem to be able to provide a solution, I...
|
by: dasilva109 |
last post by:
Hi guys
I am new to C++ and need urgent help with this part of my code for a
uni coursework I have to submit by Thursday
//ClientData.h
#ifndef CLIENTDATA_H
#define CLIENTDATA_H
#include...
|
by: f rom |
last post by:
----- Forwarded Message ----
From: Josiah Carlson <jcarlson@uci.edu>
To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org
Sent: Monday, December 4, 2006 10:03:28 PM
Subject: Re: ...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
| |