Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 14th, 2007, 03:19 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default CS0260: Missing partial modifier on declaration of

Hi all!

Can someone tell me why I am getting the following error?
Thank you in advance.

Error:
CS0260: Missing partial modifier on declaration of type 'XmlDB.Web.XmlDbTester'; another partial declaration of this type exists

Source Error:

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Data.SqlClient;
using System.Configuration;
using XmlDB.Component;
namespace XmlDB.Web {



Line 11: //
Line 12: //
Line 13: public class XmlDbTester : System.Web.UI.Page {
Line 14: public XmlDbTester() {
Line 15: Page.Init += new System.EventHandler(Page_Init);


Line: 13
Reply With Quote
  #2 (permalink)  
Old November 14th, 2007, 03:49 PM
Friend of Wrox
 
Join Date: Nov 2007
Location: Central Florida, USA.
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
Default

close it with } at line 13

Reply With Quote
  #3 (permalink)  
Old November 14th, 2007, 03:50 PM
Friend of Wrox
 
Join Date: Nov 2007
Location: Central Florida, USA.
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
Default

sorry i meant you need to close the class with } not at line 13

Reply With Quote
  #4 (permalink)  
Old November 14th, 2007, 03:54 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

The error message is probably spot on. Does this fix the problem:
Code:
public partial class XmlDbTester : System.Web.UI.Page    {
Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #5 (permalink)  
Old November 14th, 2007, 06:04 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your reply!

Partial solved the modifier error and came up with a new namespace error!

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'XmlDB' could not be found (are you missing a using directive or an assembly reference?)
Source Error:

Line 6: using System.Configuration;
Line 7:
Line 8: using XmlDB.Component;
Line 9: //
Line 10: //

I am using one class from using XmlDB.Component namespace. I have compiled the file containing the xmlDB.component namespace and the .dll is in a bin dir. I have no idea why it is complaining.
Any help is appreciated.




Reply With Quote
  #6 (permalink)  
Old November 14th, 2007, 07:03 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Are you sure the namespace and its capitalization is correct? Does your DLL really contain a namespace called xmlDB.component ? Or is it XmlDB.Component

Or maybe Component is a class instead of a namespace?

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #7 (permalink)  
Old November 14th, 2007, 07:08 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The spelling is ok. I have checked it several times. I will post the code tomorrow.

Reply With Quote
  #8 (permalink)  
Old November 15th, 2007, 02:20 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am still getting namespce error. Here is the code I am using to insert xml fields into database tabel (tblClient).

[u]client.xml</u>
<?xml version="1.0" ?>
<infocustomer>
  <customer id="2">
    <infoorganization>
        <nameInfo>
        <organizationName>Hollywood.</organizationName>
        <infocontact name="Hary Potter" title="actor" />
        </nameInfo>
    </infoorganization>
  </customer>
</infocustomer>

[u]web.config </u>
under C:\inetpub\wwwroot
<configuration>
       <appSettings>
           <add key="dsn"
    value="Server=.\SQLEXPRESS;uid=sa;pwd=xxxx;databas e=clientdata" />
       </appSettings>
</configuration>

[u]Tester.aspx</u>

<%@ Page language="c#" CodeFile="Tester.aspx.cs" AutoEventWireup="false" Inherits="XmlTest.Tester" %>



[u]Tester.aspx.cs</u>
using XmlData;
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Data.SqlClient;
using System.Configuration;


namespace XmlTest {

    public partial class Tester : System.Web.UI.Page {
        public Tester() {
            Page.Init += new System.EventHandler(Page_Init);
        }

        private void Page_Load(object sender, System.EventArgs e) {
            string xmlPath = Server.MapPath("client.xml");
            MakeSQL make = new MakeSQL();
            DetailSQL detail = make.MakeSQLProcedure(xmlPath);
            if (detail.Status == 0) {
                Response.Write("<b>SQL Output:</b><p />" + detail.SQL + "<p />");

                //Execute the SQL statement
                SqlConnection conn = null;
                try {
                    string connStr = System.Configuration.ConfigurationManager.AppSetti ngs["dsn"];
                    conn = new SqlConnection(connStr);
                    SqlCommand cmd = new SqlCommand(detail.SQL,conn);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    Response.Write("<b>Database updated!</b>");
                }
                catch (Exception exp) {
                    Response.Write("<b>Error: </b>" + exp.Message);
                }
                finally {
                    conn.Close();
                }

            } else {
                Response.Write("<b>Error Occurred:</b><p />" + detail.StatusMessage);
            }
        }

        private void Page_Init(object sender, EventArgs e) {

            InitializeComponent();
        }



        private void InitializeComponent()
        {
            this.Load += new System.EventHandler(this.Page_Load);

        }

}
}

[u]ReadXml.cs</u>

using System;
using System.Text;
using System.Collections;
using System.Xml;


namespace XmlData {

    public class MakeSQL {

        public DetailSQL MakeSQLProcedure(string xmlPath) {
            bool error = false;
            XmlTextReader reads = null;
            StringBuilder st = new StringBuilder();
            Hashtable fnv = new Hashtable();

            DetailSQL detail = new DetailSQL();

            try {
                reads = new XmlTextReader(xmlPath);

                while (reads.Read()) {
                    if (!error) {
                        if (reads.NodeType == XmlNodeType.Element) {

                            switch (reads.Name.ToLower()) {
                                case "customer":
                                    if (reads.HasAttributes) {
                                        string customerID = reads.GetAttribute("id");
                                        if (customerID != String.Empty) {
                                            fnv.Add("CustomerID","'" + customerID + "'");

                                        } else {
                                            detail.Status = 1;
                                            detail.StatusMessage = "id does not exist";
                                            detail.SQL = null;
                                            error = true;
                                        }
                                    } else {
                                        detail.Status = 1;
                                        detail.StatusMessage = "attribute does not exist";
                                        detail.SQL = null;
                                        error = true;
                                    }
                                    break;
                                case "infoorganization":
                                    string organizationName = reads.ReadString();
                                    if (organizationName != String.Empty) {
                                        fnv.Add("OrganizationName","'" + organizationName + "'");
                                    } else {
                                        detail.Status = 1;
                                        detail.StatusMessage = "OrganizationName does not exist";
                                        detail.SQL = null;
                                        error = true;
                                    }
                                    break;
                                case "infocontact":
                                    if (reads.HasAttributes) {
                                        fnv.Add("InfoName","'" + reads.GetAttribute("name") + "'");
                                        fnv.Add("InfoTitle","'" + reads.GetAttribute("title") + "'");
                                    }
                                    break;
                            } //switch
                        } //for nodeType
                    } else {
                        break;
                    }
                    if (reads.NodeType == XmlNodeType.EndElement) {
                        if (reads.Name.ToLower() == "customer") {
                            string[] fv = Enumerating(fnv,',');
                            string ds = fv[0];
                            string fl = fv[1];
                            st.Append("INSERT INTO tblClient (" + ds + ") VALUES (" + fl + ");");
                            fnv.Clear();
                        }
                    }
                }
                if (!error) {
                    detail.Status = 0;
                    detail.StatusMessage = String.Empty;
                    detail.SQL = st.ToString();
                }

                return detail;

            } catch (Exception exp) {
                detail.Status = 1;
                detail.StatusMessage = exp.Message + "\n\n" + exp.StackTrace;
                detail.SQL = null;
                return detail;
            }
            finally {
                if (reads != null) reads.Close();
            }
        }

        private string[] Enumerating(Hashtable en,char spil) {
            int len = en.Count;
            int i = 0;
            StringBuilder subf = new StringBuilder();
            StringBuilder subv = new StringBuilder();
            IDictionaryEnumerator enu = en.GetEnumerator();
            while (enu.MoveNext()) {
                subf.Append(enu.Key);
                if (i < len -1) subf.Append(spil);
                subv.Append(enu.Value);
                if (i < len -1) subv.Append(spil);
                i++;
            }
            string[] result = {subf.ToString(),subv.ToString()};
            return result;
        }

    }


    public struct DetailSQL {
        int _status;
        string _statusMessage;
        string _sql;

        public int Status {
            get {
                return _status;
            }
            set {
                _status = value;
            }
        }
        public string StatusMessage {
            get {
                return _statusMessage;
            }
            set {
                _statusMessage = value;
            }
        }
        public string SQL {
            get {
                return _sql;
            }
            set {
                _sql = value;
            }
        }
    }

}

[u]Error I am still getting</u>

Server Error in '/xmlTester' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'XmlData' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 1: using XmlData;Line 2: using System;
Line 3: using System.ComponentModel;


Source File: c:\Inetpub\wwwroot\xmlTester\Tester.aspx.cs Line: 1

I am having XmlData.ddl Under C:\inetpub\wwwroot\bin directory.

Please help to figure out the reason why I am getting the above error.
Thank you in advance.

Reply With Quote
  #9 (permalink)  
Old November 15th, 2007, 02:49 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Maybe the error message is correct and you need to add an assembly reference?

Right-click your project and choose Add Reference. Then browse to the DLL.

Also, make sure that the bin folder you are referring to is really the /bin folder of your site.

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote
  #10 (permalink)  
Old November 15th, 2007, 03:00 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi again!
I do not see Add reference when I click my project. Both XmlTest.dll and XmlData.dll are under bin directory.




Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Friend access modifier acts as private sandeep ASP.NET 2.0 Professional 2 July 19th, 2007 07:35 AM
Unknown Modifier Error - Regular Expression Beebs BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 March 20th, 2007 05:48 PM
Partial Session Lost kiasemoto Classic ASP Professional 0 January 25th, 2007 03:54 AM
Modifier use within the viod main() Ibn_Aziz Java Basics 2 June 3rd, 2006 10:08 PM
Modifier Keys shadowpug VB.NET 2002/2003 Basics 2 March 31st, 2004 12:20 PM



All times are GMT -4. The time now is 08:48 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.