PDA

View Full Version : VBA & Get Select Result in visio



unicorn4007
09-11-2009, 01:09 PM
:yes:rotlaugh::help:bug:
Hi , I work with VBA in visio , and i conected to my Instance in sql sever 2005
,and now i want execute Select query and get the result of this query from one of my table.
i dont know how can i retrive the result of this qury without datatabel, database , and qureyDef

i cant define DAO.Database , QueryDef ,...

i use below code to conect database


Const DB_CONNECT_STRING = "Provider=SQLOLEDB.1;Data Source=unicorn-pc\mssqlserver2005;Initial Catalog=EEPDC;user id ='sa';password='12345'"

Set MyConn = CreateObject("ADODB.Connection")

Set myCommand = CreateObject("ADODB.Command")

MyConn.Open DB_CONNECT_STRING

Set myCommand.ActiveConnection = MyConn

myCommand.CommandText = "select RevisionID from dbo.Revision where ObjectID_FK=1 "


myCommand.Execute

MyConn.Close

Bob Phillips
09-12-2009, 02:15 AM
Hi unicorn4007,

What exactly is the problem that you are having? Is it getting the data from SQL Server, using it in Visio, or what?

unicorn4007
09-12-2009, 06:24 AM
Hi Xld
in C# when we want access to data , after select it from Database , we store data in DataTable and we can use it .( use dataadapter and datatabel)
in VBA Programing in visio , i dont have this object , i want to know how can i get this data.
i want show this data in lables that i insert in my page .

Bob Phillips
09-12-2009, 01:40 PM
Using DAO and ADO you can query the SQL SEerver database and it returns a recordset. This consists of Fields (column names) and items (data rows). This should get you what you want.

unicorn4007
09-13-2009, 01:22 AM
Hihow can i used DAO ? how can i add this to my progect ?i cant define DAO.database or Querydef ?do i need to add somthing to my project for DAO ?

unicorn4007
09-14-2009, 12:57 PM
thanks , i found how can i solve this problem



Hihow can i used DAO ? how can i add this to my progect ?i cant define DAO.database or Querydef ?do i need to add somthing to my project for DAO ?