Query = "Select count(*) as ab from item"
ConnectionString = "DRIVER={SQL SERVER};SERVER=servername;Database=dbname;User Id=user123;Password=pass123;"
Set DBConnection = CreateObject("ADODB.Connection")
Set DBRows = CreateObject("ADODB.Recordset")
'* Open connection
DBConnection.Open connectionString
if err.number <> 0 then
msgbox "Connection Failed"& vbcrlf & err.description
end if
'* Execute SQL
Set DBRows = DBconnection.Execute(Query)
if err.number<> 0 then
msgbox "Querying Failed"& vbcrlf & err.description
end if
msgbox DBRows("ab")
'While Not DBRows.EOF
'Msgbox DBRows.Fields.Value
'DBrows.MoveNext
'Wend
DBconnection.Close
Set DBRows = Nothing
Set DBconnection = Nothing
Monday, November 9, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment