Solved

connect sql using vb

Posted on 2006-06-30
1
250 Views
Last Modified: 2013-11-23
how can i connect ms sql by vb using ADODB. Please help
0
Comment
Question by:ajaypappan
1 Comment
 
LVL 11

Accepted Solution

by:
leclairm earned 125 total points
ID: 17018090
dim oConn as adodb.connection
dim rs as adodb.recordset
set oConn = new adodb.connection
set rs = new adodb.recordset
oconn.open "Provider=sqloledb;Data Source=dbServer;Initial Catalog=YourDb;User Id=YourUser;Password=YourPassword;"
rs.open "select * from yourtable", oConn

if not rs.eof and not rs.bof then
   do some processing...
end if


Don't forget to set your reference to the ado library.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question