-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule.vb
52 lines (50 loc) · 1.63 KB
/
Module.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Module [Module]
Public db As New ADODB.Connection
Public rs As New ADODB.Recordset
Public sql As String
Public compName = Environment.MachineName
Public session As Boolean
Public sessionUser As String
Public sessionLevel As String
Public updateLevel As Boolean
Public rowValue As String
Sub conBanco()
Try
db = CreateObject("ADODB.Connection")
db.Open("Provider=SQLOLEDB;Data Source='" & Environment.MachineName & "';Initial Catalog=sgh;trusted_connection=yes;")
MsgBox("Conectado com sucesso!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "AVISO")
Catch ex As Exception
MsgBox("Conexão mal sucedida", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "AVISO")
End Try
End Sub
Function numGen()
Dim num As Integer
Dim result As Integer
sql = "select * from info"
rs = db.Execute(sql)
If rs.EOF And rs.BOF Then
If rs.RecordCount <= 0 Then
result = 0
Else
num = CInt(rs.Fields(0).Value)
If num = 0 Then
result = 1
Else
result = num + 1
End If
End If
Else
sql = "SELECT MAX(id) from info"
rs = db.Execute(sql)
If rs.EOF = False Then
num = CInt(rs.Fields(0).Value)
If num = 0 Then
result = 1
Else
result = num + 1
End If
End If
End If
Return result
End Function
End Module