最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
[ASP.NET]对Oracle数据库创建表/判断数据表是否已存在
时间:2022-06-30 10:40:10 编辑:袖梨 来源:一聚教程网
对Oracle数据库创建表:
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];Data 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()
判断数据表是否已存在:
'DataBaseName --表名
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
'小写英字转换成大写英字
'enString -- 字符串
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
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];Data 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()
判断数据表是否已存在:
'DataBaseName --表名
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
'小写英字转换成大写英字
'enString -- 字符串
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
相关文章
- 无期迷途主线前瞻直播总结 无期迷途主线前瞻直播内容介绍 11-22
- 以下哪种非遗技艺是用针在纸上绣画 蚂蚁新村11月21日答案 11-22
- 江南百景图听风塔怎么样 11-22
- 原神恰斯卡圣遗物怎么搭配 11-22
- 2024年霸王茶姬11月22日口令是什么 2024.11.22霸王茶姬口令介绍 11-22
- 光遇11.21季节蜡烛在哪里 光遇11月21日季节蜡烛位置攻略 11-22