我有一个使用 .Net 驱动程序连接到 Mysql 的 winforms 应用程序。我编写了一个类来处理所有数据库功能。我使用数据表来存储查询结果,以便从 mysql 进行绑定。
Imports MySql.Data.MySqlClient
Imports System.IO
Public Class MysqlConSjC
Private conn As MySqlConnection
Private connStr As String
Public strace As String
Private status As Integer
'status member variable for connectivity. 0 for success,
'value of one indicates db connection error
'value of 2 indicates query failure
Private comd As MySqlCommand
Private adpter As MySqlDataAdapter
Private dta As DataTable
Public Sub Query(ByVal SQl As String)
Try
comd.Connection = conn
comd.CommandText = SQl
adpter.SelectCommand = comd
adpter.Fill(dta)
status = 0
Catch ex As MySqlException
strace = ex.StackTrace()
DisconnectMysql()
status = 2
End Try
End Sub
此方法执行选择查询。我将如何编写一种方法来插入/更新/删除数据库中 DataTable 的行?