473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Mapping problem with ADO.NET


Hi,

I'm trying to establish table mappings, and I've hit a snag.

At the point to where I try to fill the schema (DB_adapter.FillSchema),
I get an exception, and the message is as follows:
:::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::
Invalid column name 'Unique_ref'.
Invalid column name 'ID_string'.
Invalid column name 'Sequence'.
:::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

I don't get it. Why doesn't it use the mapping?

I'm probably doing something dumb, so feel free to call me names
and gloat over my inferior mental capacity.

I'm using ASP.NET version 2.0.

My code is as follows:
:::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

private SqlConnection sql_connctn;
private SqlDataAdapter DB_adapter;
private DataTable Ctrl_ID_key_set_table;
private bool connctn_OK;

private const string
SQL_DB_server = "COMP-NAME-BASIC\\SQL2005DEV";

private const string
SQL_DB = "Init01";

private const string
DB_ctrl_struct_table_name = "dbo.Ctrl_Init_Struct01";

private const string
ctrl_struct_table_name = "Ctrl_Init_Struct01";

private const string
select_cmdstr = @"SELECT Unique_ref, ID_string, Sequence FROM ";

/* =============================================== */
/* =============================================== */

private SqlConnection Get_new_SQL_conn
{ get {
SqlConnectionStringBuilder
builder = new SqlConnectionStringBuilder ();

builder["Data Source"] = SQL_DB_server;
builder["Initial Catalog"] = SQL_DB;
builder["Integrated Security"] = "SSPI";

return
sql_connctn = new SqlConnection (builder.ConnectionString);
} }
/* =============================================== */
/* =============================================== */
private bool get_DB_adapter (string p_table_name)
{
bool adapter_created_ok;
SqlCommandBuilder builder;

try
{
DB_adapter
= new SqlDataAdapter
(select_cmdstr + p_table_name, sql_connctn);

builder = new SqlCommandBuilder(DB_adapter);

adapter_created_ok = true;
}
catch
{ adapter_created_ok = false; }

return adapter_created_ok;
}
/* =============================================== */
/* =============================================== */
private DataTableMapping get_struct_mapping
{ get {
DataTableMapping
mapping = new DataTableMapping
(ctrl_struct_table_name, ctrl_struct_table_name);

mapping.ColumnMappings.Add
("DB_Unique_ref", "Unique_ref");
mapping.ColumnMappings.Add
("DB_ID_string", "ID_string");
mapping.ColumnMappings.Add
("DB_Sequence", "Sequence");

return mapping;
} }
/* =============================================== */
/* =============================================== */
private bool DBtable_for_struct_datatable ()
{
try
{

using (Get_new_SQL_conn)
{
sql_connctn.Open ();

if (get_DB_adapter (DB_ctrl_struct_table_name))
{
DB_adapter.TableMappings.Add (get_struct_mapping);

Ctrl_ID_key_set_table
= new DataTable (ctrl_struct_table_name);

schema_datatable
= DB_adapter.FillSchema
(Ctrl_ID_key_set_table, SchemaType.Mapped);

connctn_OK = true;
}
else connctn_OK = false;
}

}
catch
{ connctn_OK = false; }

return connctn_OK;
}
/* =============================================== */
/* =============================================== */

:::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::
THANKS!!!

Mar 23 '06 #1
1 1700


Nevermind - situation resolved.

================================================== ============

On Thu, 23 Mar 2006 15:03:06 -0600, no**@no.com wrote:

Hi,

I'm trying to establish table mappings, and I've hit a snag.

At the point to where I try to fill the schema (DB_adapter.FillSchema),
I get an exception, and the message is as follows:
::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::
Invalid column name 'Unique_ref'.
Invalid column name 'ID_string'.
Invalid column name 'Sequence'.
::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

I don't get it. Why doesn't it use the mapping?

I'm probably doing something dumb, so feel free to call me names
and gloat over my inferior mental capacity.

I'm using ASP.NET version 2.0.

My code is as follows:
::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

private SqlConnection sql_connctn;
private SqlDataAdapter DB_adapter;
private DataTable Ctrl_ID_key_set_table;
private bool connctn_OK;

private const string
SQL_DB_server = "COMP-NAME-BASIC\\SQL2005DEV";

private const string
SQL_DB = "Init01";

private const string
DB_ctrl_struct_table_name = "dbo.Ctrl_Init_Struct01";

private const string
ctrl_struct_table_name = "Ctrl_Init_Struct01";

private const string
select_cmdstr = @"SELECT Unique_ref, ID_string, Sequence FROM ";

/* =============================================== */
/* =============================================== */

private SqlConnection Get_new_SQL_conn
{ get {
SqlConnectionStringBuilder
builder = new SqlConnectionStringBuilder ();

builder["Data Source"] = SQL_DB_server;
builder["Initial Catalog"] = SQL_DB;
builder["Integrated Security"] = "SSPI";

return
sql_connctn = new SqlConnection (builder.ConnectionString);
} }
/* =============================================== */
/* =============================================== */
private bool get_DB_adapter (string p_table_name)
{
bool adapter_created_ok;
SqlCommandBuilder builder;

try
{
DB_adapter
= new SqlDataAdapter
(select_cmdstr + p_table_name, sql_connctn);

builder = new SqlCommandBuilder(DB_adapter);

adapter_created_ok = true;
}
catch
{ adapter_created_ok = false; }

return adapter_created_ok;
}
/* =============================================== */
/* =============================================== */
private DataTableMapping get_struct_mapping
{ get {
DataTableMapping
mapping = new DataTableMapping
(ctrl_struct_table_name, ctrl_struct_table_name);

mapping.ColumnMappings.Add
("DB_Unique_ref", "Unique_ref");
mapping.ColumnMappings.Add
("DB_ID_string", "ID_string");
mapping.ColumnMappings.Add
("DB_Sequence", "Sequence");

return mapping;
} }
/* =============================================== */
/* =============================================== */
private bool DBtable_for_struct_datatable ()
{
try
{

using (Get_new_SQL_conn)
{
sql_connctn.Open ();

if (get_DB_adapter (DB_ctrl_struct_table_name))
{
DB_adapter.TableMappings.Add (get_struct_mapping);

Ctrl_ID_key_set_table
= new DataTable (ctrl_struct_table_name);

schema_datatable
= DB_adapter.FillSchema
(Ctrl_ID_key_set_table, SchemaType.Mapped);

connctn_OK = true;
}
else connctn_OK = false;
}

}
catch
{ connctn_OK = false; }

return connctn_OK;
}
/* =============================================== */
/* =============================================== */

::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::
THANKS!!!

Mar 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Frank | last post by:
Hi there, In web.xml, I know it's possible to do path mapping: <path-mapping url-pattern="/aaa/*" real-path="C:\TEMP\"/> So a call to myserver.com/mywebapp/aaa will redirect to c:\temp. ...
20
by: Pierre Fortin | last post by:
Hi! "Python Essential Reference" - 2nd Ed, on P. 47 states that a string format can include "*" for a field width (no restrictions noted); yet... >>> "%*d" % (6,2) # works as expected ' ...
6
by: naruto | last post by:
Hi all, I have the following being defined in a A.cxx file. // define in source file. Not exported to the outside world (this cannot be // moved to the header file ) #define CHANNEL_0 0...
10
by: mike | last post by:
regards: Where to find tag mapping-table of HTML translated to XHTML1.0 Any positive suggestion is welcome. thank you May goodness be with you all
1
by: Tamas Hegedus | last post by:
Hi! I am looking for an xml-object mapping tool ('XML Data Binding-design time product') where I can define the mapping rules in 'binding files' and the parser is generated automatically. ...
3
by: Elder Hyde | last post by:
I was reading this interview with Hejlsberg, when suddenly the conversation turned to O/R mapping. Hejlsberg talked as if he had had to design an O/R mapping for .NET (he said ".NET had each one of...
4
by: BentleyInc | last post by:
I'm trying to find a way to add a whildcard application mapping to aspnet_isapi.dll in IIS programmatically.... been looking into IIS administrator reference but didn't find the right function to...
6
by: Michael Tissington | last post by:
I'm trying to add some extensions to IIS on the properties, home directory, config screen. I must be missing something because the OK button is always disabled ... Any ideas please ? --...
1
by: Ram | last post by:
Hey, I'm having a trouble mapping a connecting between 2 of my tables. We have 2 tables - the simplest "dept", "emp" tables which are mapped to 2 classes. Class Dept contains 2 properties for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.