Public Module Main
Dim _desktop As Desktop = Agent.Desktop
Dim variable As String
Dim dt As String
Dim dt1 As String
Public Sub Main()
Dim myConn As New OdbcConnection
Dim dr As OdbcDataReader
Dim sql = "SELECT TOP 1000 [TPID],[TPSECURITYFLAGS] FROM [silktestsql].[dbo].[STW_PROJECTS]"
Try
'输入登录信息,此处的"silktestsql"为建立的ODBC源的连接名称,UID和PWD相信大家都懂的
myConn.ConnectionString = "DSN=silktestsql;UID=sa;PWD=51testing"
'打开连接
myConn.Open()
Catch ex As Exception
MsgBox ("Error while connecting to SQL Server: " & ex.Message, vbOkOnly)
End Try
'建立操作
Dim comm = New OdbcCommand(sql, myConn)
'执行操作
dr = comm.ExecuteReader()
'读取数据
dr.Read()