Solved

Connection to database (SQL server) beginner question

Posted on 2008-10-10
5
380 Views
Last Modified: 2012-08-13
Hello,

I just installed MS Sql server express together with Compact management.
Could somebody please give me example code to connect to a .sdf database from vb6?. If possible using DAO?
And in the code please give me an example to SELECT * from table and display the data.

Regards,
Dennis
0
Comment
Question by:Schuttend
5 Comments
 
LVL 26

Expert Comment

by:Zberteoc
ID: 22690819
what is a .sdf database?
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22690849
It's a SQL Compact standalone data file.

Here are some samples:
http://www.connectionstrings.com/?carrier=sqlserver2005ce
0
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 250 total points
ID: 22704518
OK, Brandon got you a connection string that works with .Net.

Now ... to actually put together a VB6 code snippet ...

dim cn as AdoDB.Connection

dim rs as AdoDB.Recordset
 

set cn = new AdoDb.Connection

cn.ConnectionSTring = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=myPath\myData.sdf;"
 

set rs = new adodb.Recordset

rs.Open "Select * from MyTable", cn

While not rs.Eof

  'Do something with the data

  rs.MoveNext

wend
 

rs.close

set rs = nothing

set cn = nothing

Open in new window

0
 

Author Closing Comment

by:Schuttend
ID: 31504929
thanks!
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22807839
Geez... an assist would have at least been nice.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

912 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now