Solved

Connection to database (SQL server) beginner question

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
OSQL to execute sql command 26 24
SQL Activity Monitor detail 2 23
SQL Log size 3 17
In sql, how to roll up multiple rows to only one row. 4 30
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

792 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