Showing posts with label vba. Show all posts
Showing posts with label vba. Show all posts

Monday, March 19, 2012

Connecting to MSSQL in VBA?

This is kind of the wrong place to ask VBA questions, but I've been poking around for a day and haven't got the answer, so I am hoping I can get some help here.

I am wondering if I can connect to MSSQL in MS Word Macro. If so, can I have some sample code please?

Thanks

here you go..look VBA section

http://www.programmingmsaccess.com/Samples/VBAProcs/vba_code_sample_menu.htm#VBA_Samples

|||

That's a good VB resource, however, I didn't exactly find what I was looking for.

In Excel, I can open a direct connection to a sql server like this:

ActiveSheet.QueryTables.Add( Connection:="ODBC;DRIVER=SQL Server;SERVER=myserver;UID=myid;PWD=mypass;DATABASE=mydb", _
Destination:=Range("a1"), _
SQL:="mySP")

Theoretically, I can contain a spreadsheet (as intermedia database) in Word, but before heading that direction, I want to try to get a cleaner solution first.

From the code samples I've come across, appearently ADODB or ADO, or even ODBC can only point to database file like .mdb, but not MSSQL server.

I kind of ran out of keywords for Google, so I am hoping I can get some pointers here.

|||

The first thing is Excel since XP can connect to SQL Server and write queries the syntax is Access SQL so SQL Server even version 2000 rejects some queries, the second thing is there is a team writing the type of code you need that is the Visual Studio Office Tools team. I have found two links to get you started. Hope this helps.

http://msdn2.microsoft.com/en-us/library/aa168463(office.11).aspx

http://msdn2.microsoft.com/en-us/office/aa905533.aspx

Friday, February 10, 2012

Connect to SQL Server 2000 with VB.NET for Beginners

I just started to learn Visual Basic 2005.NET. I have experience with VBA in Access and SQL Server.

I now want to build applications (client/server) with VB & SQL Server. Does anyone have a simple example with which I can start learning?

Thank you in advance!

There are many samples at the Microsoft download center. They are based either on Access or SQL Server and either on C# or VB.NET.

HTH, Jens Suessmeyer

http://www.sqlserver2005.de
|||

hi

Are your programming a windows based application or an ASP (web based) application?

joey

|||Hi Joey,

not an ASP, just a client/server application.

let's keep it simple. I'm just starting......