TSQL issues (how to populate Word document from SQL using VB)
I want in incorporate quereis in my VB.Net app to populate word documents..i am getting the data from a sql server database... Do i need to just write regular t-sql statements or do i need to begin with some type of reporting
I had partial success getting this to work against SQL Server (2005).
Query: { DATABASE \s " select top 20 FirstName from AdventureWorks.Person.Contact" " \f "1" \t "1" \l "2" }
I was able to pull data out of AdventureWorks and have it automatically populate a Word table. The only trouble is that it seems to demand a file-based DSN. I entered perfectly legal DSN-less ODBC and OLEDB connection strings for the \c option, but Word insisted on prompting me for a a file-based DSN (*.odc file found in the My Data Sources folder.)
When you wrote "i made macros" are you saying you embedded VBA inside your Word document If so, then why do you need a separate VB app You can do all your data access from VBA.
Well i made macros for certain fields where the information that can fill those fields are in my Sql sever enterprise manager..I have a VB app that opens up the letters it just doesnt populate them so i am wondering how do i get the information to populate the letters....I do have a refernce to the Word object model in my app that contains the letters i am working with.....do i decalre some datasets to work with the data
You can use TSQL to extract the data from a SQL Server database. What are you using to generate the word document Are you using the Microsoft Word Object in the COM tab in the Add Reference option If you are, you can store the results of the TSQL statement (after calling the corresponding ADO.NET objects to execute the query and retrieve the results) in a string then print this in your word document.
I have moved this thread to the "Visual Studio Tools for Office" forum because your question is not really focused on TSQL. You question is more of a Word/VB issue.
Well, i thought of that but i wanted a VB.Net interface to come up and populate the letters pertaining to different information...you put the number into the vb.net the click extract, then the vba userform comes up, and it shows you all the data pertaining to that partiuclar number then you click ok and the proper data from that particular number fills the MS word document...My data is coming from SQL Sever but i am completely drawing a blank on how to reach this....thanks 4 the help
You can use the ADO.NET objects to retrieve the data in SQL Server and populate your Word document. I will try to work on a sample application I can use to demonstrate this (if I have the free time).
TSQL issues (how to populate Word document from SQL using VB)
TSQL issues (how to populate Word document from SQL using VB)
Sih Huseyin Ulger
Are you trying to populate so-called DATABASE fields inside a Word document
See http://office.microsoft.com/en-us/assistance/HP051862061033.aspx
I had partial success getting this to work against SQL Server (2005).
Query: { DATABASE \s " select top 20 FirstName from AdventureWorks.Person.Contact" " \f "1" \t "1" \l "2" }
I was able to pull data out of AdventureWorks and have it automatically populate a Word table. The only trouble is that it seems to demand a file-based DSN. I entered perfectly legal DSN-less ODBC and OLEDB connection strings for the \c option, but Word insisted on prompting me for a a file-based DSN (*.odc file found in the My Data Sources folder.)
When you wrote "i made macros" are you saying you embedded VBA inside your Word document If so, then why do you need a separate VB app You can do all your data access from VBA.
Regards
ZainabK
oivindroed
freda123
MoonRiver000
Josh68
scubagrig
Please delete
Jimmer_BoatMan
dotnetboy
I have moved this thread to the "Visual Studio Tools for Office" forum because your question is not really focused on TSQL. You question is more of a Word/VB issue.
Thanks
Gerhard Schneider
Vinoo Cherian
Mrv153057
Jon Jarnsater
You can use the ADO.NET objects to retrieve the data in SQL Server and populate your Word document. I will try to work on a sample application I can use to demonstrate this (if I have the free time).