|
-
Jun 9th, 2006, 12:57 PM
#1
Thread Starter
Fanatic Member
perform this action only once for database
how can I check to see if a table exist in my database and if it doesn't perform this action, if it does, don't do anything? This is my code and I only want to perform this action once.
VB Code:
'this code modifies the existing database without overwriting user data
'create new table
Call CreateConnection(objConn)
objConn.Execute "CREATE TABLE TempDocAudio(n_id TEXT(50))"
Call CloseConnection(objConn)
'modify Documents and Campaign tables
Call CreateConnection(objConn)
objConn.Execute "ALTER TABLE Documents ADD COLUMN n_mp3 TEXT(50)"
'cannot use default parameters with ODBC connectivity must switch to OLEDB
objConn.Execute "ALTER TABLE Documents ADD COLUMN n_wavBol TEXT(50)DEFAULT FALSE"
'add wespak and defender columns
objConn.Execute "ALTER TABLE Campaign ADD COLUMN c_wespakOn TEXT(50)DEFAULT 1"
objConn.Execute "ALTER TABLE Campaign ADD COLUMN c_defenderOn TEXT(50)DEFAULT 1"
Call CloseConnection(objConn)
He who never made a mistake never made a discovery?
-
Jun 9th, 2006, 01:00 PM
#2
Re: perform this action only once for database
 Originally Posted by Navarone
how can I check to see if a table exist in my database
Select count(*) from sysobjects where name = 'tableyouarelookingfor'
-
Jun 9th, 2006, 01:01 PM
#3
Re: perform this action only once for database
Use the ADOX library for complete control over design of table.
-
Jun 9th, 2006, 01:05 PM
#4
Thread Starter
Fanatic Member
Re: perform this action only once for database
so like this?
VB Code:
dim sSQL as String
sSQL = "SELECT count(*) from sysobjects where name = 'TempDocAudio'"
He who never made a mistake never made a discovery?
-
Jun 9th, 2006, 01:10 PM
#5
Re: perform this action only once for database
 Originally Posted by Navarone
so like this?
VB Code:
dim sSQL as String
sSQL = "SELECT count(*) from sysobjects where name = 'TempDocAudio'"
Yep, and if your recordset = 0 it isn't there. Before putting my queries into my VB program, I always like to run them in Query Analyser to make sure they work. If you pop that one in there and use a table name you know doesn't exist, and then a table name you know does exist, you will that it will work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|