在VB中,对SQL数据库进行增删改语句如何写呢

   阅读
在VB中,对SQL数据库进行增删改语句怎么写呢?


小弟做课程设计,遇到了一点小麻烦,卡在了这里,不知道在VB中怎么写对SQL数据库的增删改。

望各位大侠给予指导,小弟先言谢了!

给一个详细的例子介绍吧!

谢谢 ... ...

------解决方案--------------------
Imports System
Imports System.Data
Imports System.Data.OleDb
Public Class dboper
Private strconn As String = "provider=SQLOLEDB;data source=.;initial catalog=pubs;user id=sa;password=;"
Private connect As New OleDbConnection
Private adapter As New OleDbDataAdapter
'聯接初始化
Public Sub InitConnection()
Try
connect = New OleDbConnection(strconn)
If (connect.State = ConnectionState.Closed) Then
connect.Open()
End If
Catch ex As Exception
End Try
End Sub
'關閉聯接
Public Sub CloseConnection()
If (connect.State = ConnectionState.Open) Then
connect.Close()
End If
End Sub
'查詢返回一個表
Public Function getTable(ByVal sql As String) as DataTable
Try
Me.InitConnection()
Me.adapter = New OleDbDataAdapter(sql, Me.connect)
Dim dt As New DataTable
Me.adapter.Fill(dt)
Me.adapter.Update(dt)
Return dt
Catch e As Exception
End Try
End Function

Public Sub NoResultSQL(ByVal sql As String) ''insert,delete,update
Try
Me.InitConnection()
Me.adapter.SelectCommand = New OleDbCommand(sql, connect)
Me.adapter.SelectCommand.ExecuteNonQuery()
Catch e As Exception
End Try
End Sub
End Class
阅读