Files
TSUserReporter/cSQL.vb
2019-10-24 16:47:06 +02:00

77 lines
2.1 KiB
VB.net

Imports System.Data.SqlClient
Public Class cSQL
Public Shared Sub SQL2DS(ByRef selector As String, ByRef ds As DataSet)
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = cRes.DBConString
cmd.Connection = con
Dim dataadapter As New SqlDataAdapter(selector, con)
con.Open()
dataadapter.Fill(ds)
con.Close()
End Sub
Public Shared Sub UpdateSQL(ByRef table As String, ByRef values As String, ByRef where As String)
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = cRes.DBConString
cmd.Connection = con
con.Open()
cmd.CommandText = "UPDATE " & table & " SET " & values & " WHERE " & where & ""
cmd.ExecuteNonQuery()
con.Close()
End Sub
Public Shared Sub InsertSQL(ByRef table As String, ByRef insert As String)
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = cRes.DBConString
cmd.Connection = con
con.Open()
cmd.CommandText = "INSERT INTO " & table & " " & insert & ""
cmd.ExecuteNonQuery()
con.Close()
End Sub
Public Shared Sub DeleteSQL(ByRef table As String, ByRef where As String)
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = cRes.DBConString
cmd.Connection = con
con.Open()
cmd.CommandText = "DELETE FROM " & table & " WHERE " & where & ""
cmd.ExecuteNonQuery()
con.Close()
End Sub
End Class
Public Class SQLVariable
Private Text, Value As String
Private prim As Boolean
Public Sub New(ByVal btext As String, ByVal bvalue As String, Optional bprim As Boolean = False)
Me.Value = bvalue
Me.Text = btext
End Sub
Public ReadOnly Property SQLText() As String
Get
Return Text
End Get
End Property
Public ReadOnly Property SQLValue() As Object
Get
Return Value
End Get
End Property
End Class