473,808 Members | 2,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8567
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**********@h otmail.com> wrote in message
news:qp5Kb.1762 0$7D3.3391@fed1 read02...
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*******@hotm ail.nospam.com> wrote in message
news:uu6Kb.5945 5$I07.257367@at tbi_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**********@h otmail.com> wrote in message
news:qp5Kb.1762 0$7D3.3391@fed1 read02...
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
22728
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 structure and rows.I tried with the following command create Table test1 as select * from test; But it give an syntax error.I have tried the same command in Oracle
0
1049
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
5816
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) ); There is a file file.del containing data for col2,col3,col4. Data for
12
2207
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: -- Initialize the temp tables............ create procedure myschema.init_ebom_tables ( ) language sql
3
10330
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 -> If I don’t comment out the As String, I get an “Expected end of statement” error – is this correct?? qt_file = Command -> This doesn’t appear to be correct – when I echo out qt_file it’s null qtApp.Test.DataTable.Import qt_file ' Import data...
3
20315
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 index on it gave me error DROP TABLE tmp DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it
1
12775
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 in CREATE TABLE statement." For what it's worth, when tested independently, the "SELECT " part of my CREATE TABLE statement works properly. Sub test() Dim cmd As ADODB.Command Set cmd = New ADODB.Command
13
4529
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 command set consisting of several single letter commands which take no arguments. A few additional single letter commands take arguments:
3
18722
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, working with complex reports is tricky Assumption: Reader of this article have basic knowledge of creating data reports. Creating a Parent-Child Command and create a DataReport Suppose we have a database called company with two tables ...
0
10631
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10374
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10114
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9196
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.