Public Conn As OleDb.OleDbConnection
Public rs As New OleDb.OleDbDataAdapter
Public query As String
Public TempName As String
Public Sub iUpdate()
rs = New OleDb.OleDbDataAdapter(query, Conn)
rs.UpdateCommand = New OleDb.OleDbCommand
rs.UpdateCommand.CommandText = query
rs.UpdateCommand.Connection = Conn
Conn.Open()
rs.UpdateCommand.ExecuteNonQuery()
Conn.Close()
End Sub
Public Sub iSave()
rs = New OleDb.OleDbDataAdapter(query, Conn)
rs.InsertCommand = New OleDb.OleDbCommand
rs.InsertCommand.CommandText = query
rs.InsertCommand.Connection = Conn
Conn.Open()
rs.InsertCommand.ExecuteNonQuery()
Conn.Close()
End Sub
Public Sub iDelete()
rs = New OleDb.OleDbDataAdapter(query, Conn)
rs.DeleteCommand = New OleDb.OleDbCommand
rs.DeleteCommand.CommandText = query
rs.DeleteCommand.Connection = Conn
Conn.Open()
rs.DeleteCommand.ExecuteNonQuery()
Conn.Close()
End Sub
Public Sub iRead()
Conn.Open()
rs = New OleDb.OleDbDataAdapter(query, Conn)
rs.Fill(ds, TempName)
Conn.Close()
End Sub
วิธีใช้ Code (VB.NET)
If Conn Is Nothing Then Conn = New OleDb.OleDbConnection("Provider=SQLOLEDB;Data Source=127.0.0.1;Initial Catalog=test;User ID=sa;PASSWORD=master;")
If ds.Tables("ClubmmEXP") IsNot Nothing Then
ds.Tables("ClubmmEXP").Rows.Clear()
End If
query = "Select * from Clubmm where Clubmm_mac ='" & DMyCom & "'"
TempName = "ClubmmEXP"
iConn.iRead()
If ds.Tables("ClubmmEXP").Rows.Count > 0 Then
Dim Code As String
Dim Key As String
Dim day As String
Code = Mid(ds.Tables("ClubmmEXP").Rows(0).Item("clubmm_exp"), 1, InStr(ds.Tables("ClubmmEXP").Rows(0).Item("clubmm_exp"), "-") - 1)
Key = Mid(ds.Tables("ClubmmEXP").Rows(0).Item("clubmm_exp"), InStr(ds.Tables("ClubmmEXP").Rows(0).Item("clubmm_exp"), "-") + 1)
day = objCSCipher.Decrypt(Key, Code)
Dim DateExp As New System.DateTime(Mid(day, 5), Mid(day, 3, 2), Mid(day, 1, 2))
Dim DateNow As New System.DateTime(Now.Year, Now.Month, Now.Day)
Return DateDiff(DateInterval.Day, DateNow, DateExp)
Else
Return 0
End If
ประมาณนี้
Date :
2010-06-16 10:48:45
By :
qqq
No. 5
Guest
สวัสดีค่ะ
ของน้ำต้องการเพิ่มค่าที่คอลัมน์ ของ record ที่มีข้อมูลตรงกับค่าที่ถูกสแกนได้อ่ะค่ะ