473,388 Members | 1,309 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,388 software developers and data experts.

Data type conversion question

I'm writing code (in VB.NET/2005) to create a SQL Server database from some
"other" database (user selected). So I "connect" to it and then use the
GetSchema method options to retrieve its characteristics to create/define
the new SQL Server database and (optionally) populate it with data from the
old database.

Using the GetSchema("Columns", restrictions) method, I get a data table back
showing the datatypes of the columns in the selected (old) table. They show
up as a number (e.g. a "12" is a varchar) and a name. Then there's the size,
number of decimals etc.

Question is:
Is there a way to use this information to specify the SMO datatype without
having to go through a whole whack of "Select Case" statements to deal with
each separate incoming datatype?

I'm trying to avoid a whole series of statements like this:
Select Case <input datatype number>
Case 12
col.DataType =
Microsoft.SqlServer.Management.Smo.DataType.VarCha r(COLUMN_SIZE)

This does work but it's a lot of coding and there's too great a potential
for missing one (or more) valid case(s)

May 11 '06 #1
3 1991
Hi Sam,

an idea could be giving the possibility to the user to remap fields. In
fact, if your purpose is somehow to pass data from a database to
another, very often the user will not restrict himself to tables, but
he may want to make queries. In general you might provide a panel wher
the user can see the "origin" types and the possible "target" types and
for each origin type he can indicate the target type. This is also
useful because given an "origin" type the user can choose different
target types on diffrent taget databases... (btw is your origin
arbitrary or necessarily sqlserver?)

What do you think?

tommaso

May 12 '06 #2
Thanks for the suggestions. I appreciate you taking the time.
What I'm doing is writing a utility that a person can use to copy a database
from one technology to another, be that SQL Server (Express or "full"),
MySQL, Oracle or MS Access. By copy, I mean tables (DDL and data), Indecies,
Views, whatever - so that (insofar as the two technologies support certain
features) they'd end up with a duplicate of the "from" database on the "to"
technology..
I can do it as in my original post but was trying to simplify the copying of
the column definition - data types so that I didn't have a couple of dozen
"Case" statements such as the one illustrated in my original post.

<to**************@uniroma1.it> wrote in message
news:11**********************@q12g2000cwa.googlegr oups.com...
Hi Sam,

an idea could be giving the possibility to the user to remap fields. In
fact, if your purpose is somehow to pass data from a database to
another, very often the user will not restrict himself to tables, but
he may want to make queries. In general you might provide a panel wher
the user can see the "origin" types and the possible "target" types and
for each origin type he can indicate the target type. This is also
useful because given an "origin" type the user can choose different
target types on diffrent taget databases... (btw is your origin
arbitrary or necessarily sqlserver?)

What do you think?

tommaso

May 12 '06 #3
That's interesting. I have done something similar, but more in a
perspective of data integration,
instead of database cloning. I had to place all the "cases" because I
was also providing the user
with the possibility to do changes when copying. Further I had to deal
with arbitrary joins done
on the origin database. However the problems are quite similar.

If you wish to share more I am available. I have accumulated some
experience on shufflying data
from a platform to another... :) thare are tons of subtleties, and
probably I have discovered only
a small part of them ... :)

-tom

May 12 '06 #4

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

Similar topics

10
by: Zap | last post by:
Widespread opinion is that public data members are evil, because if you have to change the way the data is stored in your class you have to break the code accessing it, etc. After reading this...
2
by: GrahamJWalsh | last post by:
I have a basic question regarding various data types (related to reinterpret_cast, static_cast). Lets say I have some declarations thus; int i = 444; unsigned int* uip; I then do...
11
by: theshowmecanuck | last post by:
As a matter of academic interest only, is there a way to programmatically list the 'c' data types? I am not looking for detail, just if it is possible, and what function could be used to...
19
by: Randy Yates | last post by:
Consider the following code: #include "dsptypes.h" /* definitions */ #define VECTOR_LENGTH 64 /* local variables */
27
by: Yuriy Solodkyy | last post by:
Hi VS 2005 beta 2 successfully compiles the following: using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program {
1
by: lovecreatesbeauty | last post by:
There is a warning/(error? I remember it is an error for line 10 on some compilers before. At least on g++, it is an error.) for line 10. I first read a similar example from `Expert C Programming...
6
by: NM | last post by:
I am given an int and have to tell whether the bit representation of that int is a palindrome or not. Here is what I have come up with bool isIntPalindrome(int num) { unsigned int temp = num;...
4
by: alacrite | last post by:
I have a class that I want to turn its contents into csv file. I want to be able to set the value of the delimiter, the name of the file it gets saved to, the path of that file, and maybe a few...
4
by: zaeminkr | last post by:
I got a good answer here I have still confusing part. I have two very simple classes class DRect { private : double x0, y0, x1, y1; public : DRect(double a, double b, double c, double d) :...
8
by: Smithers | last post by:
Are there any important differences between the following two ways to convert to a type?... where 'important differences' means something more profound than a simple syntax preference of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.