Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Check if table exists on IBM As400 database using Vb.net sql statement


Check if table exists on IBM As400 database using Vb.net sql statement

Author
Message
equinlan
equinlan
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
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
KenpoDBA
KenpoDBA
SSC-Addicted
SSC-Addicted (476 reputation)SSC-Addicted (476 reputation)SSC-Addicted (476 reputation)SSC-Addicted (476 reputation)SSC-Addicted (476 reputation)SSC-Addicted (476 reputation)SSC-Addicted (476 reputation)SSC-Addicted (476 reputation)

Group: General Forum Members
Points: 476 Visits: 611
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.com
Blog Author of:
DBA Rant – http://www.MidnightDBA.com/DBARant

Minion Maintenance is FREE:


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search