📄 cargo.vb
字号:
Imports System.Data.SqlClient
Public Class Cargo
Private dstCargo As DataSet
Private conCargo As SqlConnection
Dim adpCust As SqlDataAdapter
Public Sub New()
conCargo = New SqlConnection()
conCargo.ConnectionString = "Data Source=localhost;Initial Catalog=Cargo;Integrated Security=True;"
End Sub
Public Sub GetCustomers()
dstCargo = New DataSet()
adpCust = New SqlDataAdapter("Select CustomerID, FirstName, LastName, CompanyName, Email, Address from Customers", conCargo)
adpCust.Fill(dstCargo, "CustTable")
End Sub
Public ReadOnly Property CustList() As DataTable
Get
Return dstCargo.Tables("CustTable")
End Get
End Property
Public Sub EditDetails(ByVal RowNum As Integer, ByVal ID As Integer, ByVal strCompany As String, ByVal strEmail As String, ByVal strAddress As String)
Dim editRow As DataRow = dstCargo.Tables("CustTable").Rows(RowNum)
editRow.BeginEdit()
editRow("CompanyName") = strCompany
editRow("Email") = strEmail
editRow("Address") = strAddress
editRow.EndEdit()
Dim commUpdate As New SqlCommand("Update customers set CompanyName= @company, email=@email, address=@address where customerid=@id", conCargo)
commUpdate.Parameters.Add("@id", SqlDbType.Int, 4, "CustomerID")
commUpdate.Parameters.Add("@company", SqlDbType.VarChar, 50, "CompanyName")
commUpdate.Parameters.Add("@email", SqlDbType.VarChar, 255, "Email")
commUpdate.Parameters.Add("@address", SqlDbType.VarChar, 255, "Address")
adpCust.UpdateCommand = commUpdate
adpCust.Update(dstCargo, "CustTable")
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -