Solved

IBatis, XML file

Posted on 2006-11-20
5
1,542 Views
Last Modified: 2012-06-27
Hi experts,
I am using Ibatis for Database management and VS:2005(ASP.Net 2.0) tool for an app.
when I run my project, there is error from sqlMap.config file:

error:
- The error occurred while Validate SqlMap config.
- The error occurred in <sqlMap embedded="SqlMaps.ProductGroup.xml, DTWR.MarketingCampaign.Data"

Here are files from my project

1. project User Interface: 2 textboxes, 1 button--save items into product group
SqlMap.config file

<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig
  xmlns="http://ibatis.apache.org/dataMapper"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <settings>
    <setting validateSqlMap="true"/>
  </settings>

  <providers embedded="DTWR.MarketingCampaign.Data.providers.config, DTWR.MarketingCampaign.Data"/>

  <!-- Database connection information -->
  <database>
    <provider name="sqlServer2.0"/>
    <dataSource name="test" connectionString="Data Source=(local);Initial Catalog=test;User ID=sa;Password=01"/>
  </database>

  <sqlMaps>
    <sqlMap embedded="SqlMaps.ProductGroup.xml, DTWR.MarketingCampaign.Data" />
   </sqlMaps>

</sqlMapConfig>

2. project.Domain: productGroup.cs

namespace DTWR.MarketingCampaign.Domain
{
    public class ProductGroup
    {
        public string groupID;
        public string productID;

        public string GroupID
        {
            get { return groupID; }
            set { groupID = value; }
        }

        public string ProductID
        {
            get { return productID; }
            set { productID = value; }
        }
    }
}


3. Project Data: include one .xml file and one .cs file
productGroup.xml
<?xml version="1.0" encoding="utf-8" ?>
<sqlMap>
<alias>
    <typeAlias alias="ProductGroup" type="DTWR.MarketingCampaign.Domain.ProductGroup, DTWR.MarketingCampaign.Domain" />
 </alias>
 
  <parameterMap id="ProductSelection" class="ProductGroup">
    <parameter column="Selection_ID" property="groupID"/>
    <parameter column="Product_ID" property="productID"/>
  </parameterMap>

  <statement id="insertProduct" parameterMap="ProductSelection">
    insert into Product_Selection (Selection_ID, Product_ID) values (#groupID#,#productID#);
  </statement>

</sqlMap>

//////////////
productSelection.cs
using System;
using System.Collections.Generic;
using System.Text;
using DTWR.MarketingCampaign.Domain;
using DTWR.MarketingCampaign.Data;
using IBatisNet.DataMapper;

namespace DTWR.MarketingCampaign.Data.ProductManagementService
{
    public class ProductSelection
    {
        public static ProductGroup insertProduct(DTWR.MarketingCampaign.Domain.ProductGroup pg)
        {
            return Mapper.Instance().Insert("insertProduct", pg) as ProductGroup;
        }
    }
}


4. Project Logic:using System;
using System.Collections.Generic;
using System.Text;
using DTWR.MarketingCampaign.Domain;
using DTWR.MarketingCampaign.Data;
using DTWR.MarketingCampaign.Data.ProductManagementService;

namespace DTWR.MarketingCampaign.BusinessLogic
{
    public class SaveProduct
    {
        public SaveProduct(string gID, string pID)
        {
            DTWR.MarketingCampaign.Domain.ProductGroup newobj = new ProductGroup();
            newobj.groupID = gID;
            newobj.productID = pID;
            DTWR.MarketingCampaign.Data.ProductManagementService.ProductSelection.insertProduct(newobj);
        }
    }
}




0
Comment
Question by:dtwoway
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 1

Expert Comment

by:vihieu
ID: 17992477
Please try
<sqlMaps>
    <sqlMap embedded="Maps.productGroup.xml, DTWR.MarketingCampaign.Data" />
</sqlMaps>

instead of your
<sqlMaps>
    <sqlMap embedded="SqlMaps.ProductGroup.xml, DTWR.MarketingCampaign.Data" />
</sqlMaps>

in SqlMap.config file
0
 

Author Comment

by:dtwoway
ID: 17997160
Hi vihieu,

I tried your comment, it didn't work.
0
 

Author Comment

by:dtwoway
ID: 17997752
Ok,  I already fix the problem. The problem came from .XML file insert into statement. I use  
<generate table="Product_Selection" /> instead of  insert into Product_Selection (Selection_ID, Product_ID) values (#groupID#,#productID#). It works.  But I don't know when i should use insert into statement except "generate table" statement.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 18189456
PAQed with points refunded (250)

Computer101
EE Admin
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question