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

SQL command to create new table?

A simple question:

I've read a couple of things that indicates I can create a new table in my
database using some SQL command. Is this correct? I would like to load a
database into a DataSet, make changes to the existing DataTable(s), add NEW
DataTable(s) if necessary and save the changes back to the database. I'm
stuck on this problem. Any documentation on this would be great.
Thanks,
Jacob
Nov 15 '05 #1
2 8548
What database are you using?

If you are using SQL Server or MSDE, the command would be
CREATE TABLE MyTable ( field1 type, field2 type, field3 type)

I assume Access would be similar.

Better yet, use SQL DMO. These objects give you real power.

Once the table is created, you can use ordinary ADO.NET objects to create
data sets and insert records.

--- Nick

"Jacob" <ja**********@hotmail.com> wrote in message
news:qp5Kb.17620$7D3.3391@fed1read02...
A simple question:

I've read a couple of things that indicates I can create a new table in my
database using some SQL command. Is this correct? I would like to load a
database into a DataSet, make changes to the existing DataTable(s), add NEW DataTable(s) if necessary and save the changes back to the database. I'm
stuck on this problem. Any documentation on this would be great.
Thanks,
Jacob

Nov 15 '05 #2
Nick,

That worked perfectly! Unfortunately, I found I have a little different
problem that I thought I did. Creating a new table allows me to fill a
DataSet, insert records, update the database, etc... But I've written a
method that retrieves some information from the net and sends it back in the
form of a NEW DataTable. Is it possible to just "copy" this DataTable into
the DataSet and save the results to the database? I thought creating a new
table in the database first would solve this problem, but when I try to copy
the DataSet back I get an error; either that there is no mapping name (you
helped me solve this by creating a matching table name in the database) or
that there is nothing to update (I guess because the DataRowState of the
newly created table doesn't show any changes and therefore no changes are
written to the database). Would my best approach be to:

1). Copy the new DataTable row by row (in a loop) to the bound DataSet
(therefore making it look like they are all new records)?
2). Change the DataRowState to Modified in the new DataTable, and add the
table to the DataSet?
3). Pound my head on the wall?
If any of that makes sense... any extra help you could provide would be
appreciated.

Thanks,
Jacob


"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:uu6Kb.59455$I07.257367@attbi_s53...
What database are you using?

If you are using SQL Server or MSDE, the command would be
CREATE TABLE MyTable ( field1 type, field2 type, field3 type)

I assume Access would be similar.

Better yet, use SQL DMO. These objects give you real power.

Once the table is created, you can use ordinary ADO.NET objects to create
data sets and insert records.

--- Nick

"Jacob" <ja**********@hotmail.com> wrote in message
news:qp5Kb.17620$7D3.3391@fed1read02...
A simple question:

I've read a couple of things that indicates I can create a new table in my database using some SQL command. Is this correct? I would like to load a database into a DataSet, make changes to the existing DataTable(s), add

NEW
DataTable(s) if necessary and save the changes back to the database. I'm stuck on this problem. Any documentation on this would be great.
Thanks,
Jacob


Nov 15 '05 #3

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

Similar topics

2
by: Kevin | last post by:
Hi All, I am new to MS SQL Server.I am using MS SQL 2000.I have a problem in creating a table by using Select command.I have table called "test" and i want to create another table with the same...
0
by: atcproductions | last post by:
Experts, Given a script that uses the following format to create tables on the fly: CREATE TABLE $tName ( id int(11) unsigned NOT NULL auto_increment PRIMARY KEY, p_MSG text,
2
by: jay | last post by:
hi, Question on Load/import command. consider a sample table create table table_name ( col1 timestamp not null default current timestamp, col2 int, col3 int, col4 int, primary key(col1) );...
12
by: robertino | last post by:
Hi all, I've put together a few SPs to produce a BOM (bill of materials) listing, which together use a couple of global temp tables, and return the results from a cursor. Here's the code: ...
3
by: jlw16 | last post by:
Hello, I’m trying to use my vbs script to get a command line argument for a file which will need to be opened through QuickTestPro. Below are the commands I’m using: Dim qt_file 'As String ->...
3
by: db2admin | last post by:
Hello, I always assumed that dropping table will drop everything associated with it like indexes, references etc. I just noticed that after dropping table A and recreating it and then creating...
1
by: dave.j.thornton | last post by:
I'm attempting to create a new table, and populate it using the fields from two existing tables. The code is printed below. I get the error: "Run-time error '-2147217900 (80040e14)': Syntax error...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.