- NewDB.db3是一個已存在的SQLite資料庫檔案
- 要在NewDB.db3上新增一個test資料表,包含三個欄位oid, word, denotation,資料規格如程式內容。
************************************************
Imports System.Data.SQLite
Public Class Form2
Private Sub CreateTable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateTable.Click
Try
Dim zSQLFile As String = "Data Source=C:\SQLite檔案存放資料夾\NewDB3.db3"
'連接資料庫
Dim oConn As New SQLiteConnection(zSQLFile)
oConn.Open()
'執行SQL指令
Dim zSQL As String = "CREATE TABLE test(oid INTEGER PRIMARY KEY AUTOINCREMENT, word VARCHAR(50), denotation VARCHAR(255));"
Dim oCmd As SQLiteCommand = New SQLiteCommand(zSQL, oConn)
oCmd.ExecuteNonQuery()
oCmd.Dispose()
oConn.Close()
lblMsg.Text = "Table created ready!!!"
Catch ex As Exception
lblMsg.Text = ex.Message
End Try
End Sub
End Class
沒有留言:
張貼留言