473,406 Members | 2,220 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,406 software developers and data experts.

How to check a table is created in db?

In c#, Microsoft sql 2000, the name of db is "tc",and i want to check the
table "csharp" is exist or not . if it isnot exist, create it.!
======================================
SqlCommand cmd = new SqlCommand();
connection.open();
sSQL = "...." // how to write it.
cmd.CommandText = sSQL;
cmd.ExceutNonQuery();
.....
other statement
=============================
Nov 16 '05 #1
2 1580
if not exists (select table_name from information_schema.tables where
table_name ='tc')
Create table tc (....)
"zjut" <zj**@discussions.microsoft.com> skrev i en meddelelse
news:C2**********************************@microsof t.com...
In c#, Microsoft sql 2000, the name of db is "tc",and i want to check the
table "csharp" is exist or not . if it isnot exist, create it.!
======================================
SqlCommand cmd = new SqlCommand();
connection.open();
sSQL = "...." // how to write it.
cmd.CommandText = sSQL;
cmd.ExceutNonQuery();
....
other statement
=============================

Nov 16 '05 #2
Hi,

You can check if it does exist or not by querying sysobjects , those with
xtype = 'U' are tables

To create it you could send a CREATE table command.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"zjut" <zj**@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com...
In c#, Microsoft sql 2000, the name of db is "tc",and i want to check the
table "csharp" is exist or not . if it isnot exist, create it.!
======================================
SqlCommand cmd = new SqlCommand();
connection.open();
sSQL = "...." // how to write it.
cmd.CommandText = sSQL;
cmd.ExceutNonQuery();
....
other statement
=============================

Nov 16 '05 #3

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

Similar topics

2
by: Chris Windsor | last post by:
I hope the following describe what I'm trying to do: I have created a tool to be used by product analysts when studying different cell phone designs. Part of the tool is a set of 11 forms on a...
0
by: Karl Roes | last post by:
I'm still having trouble posting follow-ups. :-( "Unable to retrieve message 7cc66112.0501041919.3a6628b4@posting.google.com" Now Turtle wrote "You'll need an extra field in the table...
7
by: TJoker .NET | last post by:
I'm developing an VB.NET Windows Forms application that uses CR for VS.NET (original version shipped with VS.NET 2002 - my VS.NET has the latest SP installed, no SPs for CR). My reports get their...
1
by: scprosportsman | last post by:
Please help guys, i am trying to set up a database here at work and im fairly new to access in terms of writing functions and queries and stuff. I have 2 different places on my design that will...
1
by: DoveArrow | last post by:
I have created an Access database that is designed to send an E-Mail out to a new student's advisor using a Mail Merge. As part of this database, I have created three tables. The first table...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.