Solved

Connection to database (SQL server) beginner question

Posted on 2008-10-10
5
379 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
Comment Utility
what is a .sdf database?
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
Comment Utility
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
Comment Utility
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
Comment Utility
thanks!
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
Comment Utility
Geez... an assist would have at least been nice.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

772 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

10 Experts available now in Live!

Get 1:1 Help Now