Solved

Connection to database (SQL server) beginner question

Posted on 2008-10-10
5
381 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

777 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