[asp.net] CREATE TABLE/Judge data table for Oracle database
Source: Internet
Author: User
To create a table for an Oracle database:
Dim myConnectionString as String
Dim MyConnection as OleDbConnection
Dim MyCommand as OleDbCommand
Dim Mycreatesql as String
myConnectionString = "provider= ' oraoledb.oracle.1"; User id=[user ID];D ata source=[data Source]; Extended properties=; Persist Security info=true; Password=[password] "
MyConnection = New OleDbConnection (myconnectionstring)
Mycreatesql = "CREATE TABLE (ABC VARCHAR2 (10))"
mycommand = New OleDbCommand (mycreatesql)
Mycommand.connection = myconnection
Myconnection.open ()
Mycommand.executenonquery ()
MyCommand.Connection.Close ()
To determine whether a data table already exists:
' DataBaseName--table name
Private Function sqlexistdatabase (ByVal DataBaseName as String) as Boolean
Dim Orcconndb as OracleConnection
Dim Strselect as String
Dim Odaexistdatabase as OracleDataAdapter
Dim Dsexistdatabase as New DataSet
ORCCONNDB = New OracleConnection
orcconndb.connectionstring = "data source=[data source];" _
& "Persist Security Info=false" _
& user Id=[]user ID; Password=[password]; "
Orcconndb.open ()
Strselect = "SELECT count (*) from user_tables where Table_name= '" & Replaceen (DataBaseName) & "'"
Odaexistdatabase = New OracleDataAdapter (strselect, ORCCONNDB)
Odaexistdatabase.fill (Dsexistdatabase)
If dsexistdatabase.tables (0). Rows (0) (0) = 0 Then
Orcconndb.close ()
Return False
Else
Orcconndb.close ()
Return True
End If
End Function
' lowercase English word converted to capital English
' Enstring--string
Private Function Replaceen (ByVal enstring As String) as String
Dim I as Integer
For i = ASC ("a") to ASC ("Z")
enstring = Enstring.replace (CChar (ChrW (i)), CChar (ChrW (i-32))
Next
Return enstring
End Function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service