站內搜尋:Yahoo搜尋的結果,如果沒有給完整的網址,請在站內再搜尋一次!
2011-12-05
使用VB.net將資料插入SQLite3資料表的範例(insert into)
************************************************
Private Sub InsertData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InsertData.Click
Dim aWord(,) = {{"boy", "男孩"}, {"girl", "女孩"}, {"man", "男人"}, {"woman", "女人"}, {"student", "學生"}}
Try
Dim zSQLFile As String = "Data Source=C:\SQLite檔案存放資料夾\NewDB3.db3"
'連接資料庫
Dim oConn As New SQLiteConnection(zSQLFile)
oConn.Open()
'執行SQL指令
Dim zSQL As String = vbNullString
Dim zWord As String = vbNullString
Dim zDeno As String = vbNullString
Dim oCmd As SQLiteCommand = Nothing
For i = 0 To 4
zWord = aWord(i, 0)
zDeno = aWord(i, 1)
zSQL = "INSERT INTO test (word,denotation) VALUES ('" & zWord & "','" & zDeno & "')"
oCmd = New SQLiteCommand(zSQL, oConn)
oCmd.ExecuteNonQuery()
Next
lblMsg.Text = "Data inserted ready!!!"
oCmd.Dispose()
oConn.Close()
Catch ex As Exception
lblMsg.Text = ex.Message
End Try
End Sub
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言