R
Rui Alvares
Hi every body,
I'm not a good programmer in SQL and Visual Basic and so, I need your help.
Below is some code that gives data from a row of a table.
This data is stored in variables value_1, value_2 and value_3.
What I want is how to make code to read some rows of data stored in a table
and keep that data in various variables?
Dim conn, rst 'deklarieren der Variable 'variable declaration
Set conn = CreateObject("ADODB.Connection")
Set rst = CreateObject("ADODB.Recordset")
conn.Open "Provider=MSDASQL;DSN=WinCCFlexible"
Dim SQL_Tabelle
On Error Resume Next
SQL_Tabelle = "SELECT * FROM " & tabname_1 & " WHERE Nr = " & Dat_Nr
Set rst = conn.Execute(SQL_Tabelle)
If Not (rst.EOF And rst.BOF) Then
rst.MoveFirst
value_1 = rst.Fields(1).Value
value_2 = rst.Fields(2).Value
value_3 = rst.Fields(3).Value
name_1 = rst.Fields(1).Name
name_2 = rst.Fields(2).Name
name_3 = rst.Fields(3).Name
rst.Close
End If
Set rst = Nothing
Set conn = Nothing
Err.Clear
Thanks in advance
Rui Álvares
I'm not a good programmer in SQL and Visual Basic and so, I need your help.
Below is some code that gives data from a row of a table.
This data is stored in variables value_1, value_2 and value_3.
What I want is how to make code to read some rows of data stored in a table
and keep that data in various variables?
Dim conn, rst 'deklarieren der Variable 'variable declaration
Set conn = CreateObject("ADODB.Connection")
Set rst = CreateObject("ADODB.Recordset")
conn.Open "Provider=MSDASQL;DSN=WinCCFlexible"
Dim SQL_Tabelle
On Error Resume Next
SQL_Tabelle = "SELECT * FROM " & tabname_1 & " WHERE Nr = " & Dat_Nr
Set rst = conn.Execute(SQL_Tabelle)
If Not (rst.EOF And rst.BOF) Then
rst.MoveFirst
value_1 = rst.Fields(1).Value
value_2 = rst.Fields(2).Value
value_3 = rst.Fields(3).Value
name_1 = rst.Fields(1).Name
name_2 = rst.Fields(2).Name
name_3 = rst.Fields(3).Name
rst.Close
End If
Set rst = Nothing
Set conn = Nothing
Err.Clear
Thanks in advance
Rui Álvares