Hi,
I am creating a SQL Server tables programmatically in C#. I want to check first if a table exists and only if it doesn't exist, create one. I was looking around but I couln't find an easy way to do so.
Any ideas?
Thanks a lot ,
Rakefet
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vijaya KadiyalaPosted Apr 22, 2009, 3:55 PM
Hi
Instead of making a call to find out wheather table is there or not, i will issue CREATE table statement and if there are errors during this process i would like to handle it in Catch block.
Thanks
-- Vijaya Kadiyalawww
.DotNetVJ.comVijaya KadiyalaPosted Apr 22, 2009, 3:55 PM
Hi
Instead of making a call to find out wheather table is there or not, i will issue CREATE table statement and if there are errors during this process i would like to handle it in Catch block.
Thanks
-- Vijaya Kadiyalawww
.DotNetVJ.comramesh pPosted Apr 21, 2009, 3:53 AM
try{
DbOpen();TABLE MyNewName(PersonID COUNTER PRIMARY KEY, FirstName varchar(20), LastName varchar(20))"; DBConnection););
string strStatement = "CREATE
OleDbCommand DBCommand = new OleDbCommand(strStatement,
DBCommand.ExecuteNonQuery(
DbClose();
}catch(Exception EX)
{
}
PatriciaPosted Mar 17, 2006, 10:38 AM
Tim HeapPosted Mar 17, 2006, 9:37 AM
venkata naiduPosted Mar 15, 2006, 9:08 AM
{
Create Table
//if table already is there,then it raise the exception.
//otherwise if table not there it create the table
}
Catch
{
do nothing
// if table already is there then only it comes.
}