Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Check if table exists on IBM As400 database using Vb.net sql statement Expand / Collapse
Author
Message
Posted Monday, June 23, 2008 8:36 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, February 16, 2011 8:08 AM
Points: 1, Visits: 7
I'm trying to check if a table exist on my IBM As400 database.
I'm using Vb.net to create an application, which runs sql statements and sends them via an ODBC connection to the AS400.
99% of my app works, but I want to be able to check if a table exist before running any SQL's.

I've seen some examples on the net and in the forums such as the following:

--===== If the test table already exists, drop it IF OBJECT_ID('TempDB..#mytable','U') IS NOT NULL DROP TABLE #mytable

However, I'm not sure if my OBJECT_ID is not set properly or IBM doesn't like some of the commands being sent to it.

For instance in my create table statement I do the following:



query = "CREATE TABLE " & tmptable _
& " (PRPROP CHAR(30) CCSID 37 DEFAULT NULL, " _
etc......

ODBC_SQL()

Private Sub ODBC_SQL()
ODBC_DataAdapter = New Odbc.OdbcDataAdapter(ODBC_Command)
ODBC_DataAdapter.SelectCommand = New System.Data.Odbc.OdbcCommand(query, ODBC_connect)
Cama_tbl.Reset()
ODBC_DataAdapter.Fill(DataSet, "Cama_tbl")
End Sub


My create table statement works fine, and if I add a "DROP" table statement it works too. However, I basically want to check if the table exist first before I create the table so I won't get any error messages.

Any help is appreciated.
Eddie
Post #521859
Posted Monday, June 23, 2008 8:58 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, November 17, 2014 3:55 PM
Points: 320, Visits: 362
Sorry dude, this is not an IBM forum. I would suggest trying one of those. You may have better luck.

Watch my free SQL Server Tutorials at:
http://MidnightDBA.ITBookworm.com

Read my book reviews at:
www.ITBookworm.com

Blog Author of:
Database Underground -- http://www.infoworld.com/blogs/sean-mccown
DBA Rant – http://dbarant.blogspot.com
Post #521883
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse