473,811 Members | 2,869 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple Database Connection Code

Does anyone have some basic code and the corresponding resources needed that
will enable me to connect to an Access Database in .net compact frmwrk using
C#. I need to learn how to create a recordset and do some reading, updating
and appending. I can't seem to find any straight forward examples. It's all
blah, blah, blah. I would appreciate any code that I can build on.

Thank you.
Nov 16 '05 #1
4 2368
Thu. Aug. 26, 2004 10:10 PM PT

MyDataBase = your Access .MDB file, give a full path of your file location,
check the syntax
MyTable = your table in Access database.
If you want ODBC connection string Let me know.
I hope this will solve your probs.

Good Luck.
[C#]
// OLE DB Driver string for MS Access database

SqlConnection con = new SqlConnection(( "Data
Source="c:\\tem p\\MyDataBase.m db";Provider=\" Microsoft.Jet.O LEDB.4.0\";Jet
OLEDB:Engine Type=5;");
SqlCommand cmd = con.CreateComma nd();
cmd.CommandText = "Select from MyTable";
cmd.ExecuteQuer y();
or
cmd.ExecuteRead er();
con.Close()
"Poewood" <Po*****@discus sions.microsoft .com> wrote in message
news:2D******** *************** ***********@mic rosoft.com...
Does anyone have some basic code and the corresponding resources needed that will enable me to connect to an Access Database in .net compact frmwrk using C#. I need to learn how to create a recordset and do some reading, updating and appending. I can't seem to find any straight forward examples. It's all blah, blah, blah. I would appreciate any code that I can build on.

Thank you.

Nov 16 '05 #2
Hi Poewood,

The connection strings can be found here:

http://www.connectionstrings.com/

You can use OleDbDataAdapte r to fill data from the database into a dataset.
You can use the same dataadapter to write data back to the database.

Maybe one of these are what you are looking for:

http://www.codeproject.com/cs/databa...rpaccessdb.asp
http://www.c-sharpcenter.com/Tutoria...aseConn_01.htm
http://c-sharpcenter.com/Tutorial/Database2.htm
http://c-sharpcenter.com/Tutorial/DB_part3.htm
http://www.c-sharpcenter.com/Tutorial/DB_part4.htm

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3
"Poewood" <Po*****@discus sions.microsoft .com> wrote in message
news:2D******** *************** ***********@mic rosoft.com...
Does anyone have some basic code and the corresponding resources needed
that
will enable me to connect to an Access Database in .net compact frmwrk
using
C#. I need to learn how to create a recordset and do some reading,
updating
and appending. I can't seem to find any straight forward examples. It's
all
blah, blah, blah. I would appreciate any code that I can build on.


There's no Access database driver for the Compact Framework. I'd suggest SQL
Server CE.

Tim
Nov 16 '05 #4
But isn't the SQL Server CE database really a "pocket Access Dbase"? How do
I convert an Access Database to a SQL Server CE databse?

"Tim Anderson" wrote:
"Poewood" <Po*****@discus sions.microsoft .com> wrote in message
news:2D******** *************** ***********@mic rosoft.com...
Does anyone have some basic code and the corresponding resources needed
that
will enable me to connect to an Access Database in .net compact frmwrk
using
C#. I need to learn how to create a recordset and do some reading,
updating
and appending. I can't seem to find any straight forward examples. It's
all
blah, blah, blah. I would appreciate any code that I can build on.


There's no Access database driver for the Compact Framework. I'd suggest SQL
Server CE.

Tim

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
15974
by: Dariusz | last post by:
I am a beginner in PHP and MySQL, and am working through a book and various online tutorials on PHP and MySQL and now stuck - installed everything on "localhost" and it all works fine. My question is as follows. I have a guestbook type code I'm trying to write, but when the results get printed to a webpage, it outputs completely nothing as what was entered in the guestbook database. No errors appear to be generated, and I can't see if...
13
4759
by: Samantha Smit | last post by:
Hi, I am trying to create a simple asp page that has one command button that updates a database. The URL of the page is like this: http://MyServer.com/Update.asp?UserName=Tom My asp code is like this: %@ Language=VBScript %> <!--#include file="includes/openconnection.asp"-->
9
12340
by: Pete | last post by:
Does anyone have a simple html vbscript or other type of snippet they can share that appends a record to a access database via ADO or DAO? I would like to allow users that don't have Microsoft Access a way of adding records to a access database from a simple web page. I don't want to have to setup ODBC or anything like that I just want to put the web page on the network for anyone to access. Most of the users would use the local access...
1
1871
by: Anonymous via the Cypherpunks Tonga Remailer | last post by:
Hi, I'm building a simple Object Oriented CMS using PHP5 and the new object model (new to both). I'm looking for some design advice on how best to integrate the database class - which creates the db connection and executes the sql queries. In my particular case, I have 3 objects (classes) that I instantiate from a given script (call it index.php). Each must have access to the database. So, do I create a db connection
2
4152
by: Brad | last post by:
Where is the connection string stored for a simple Crystal Report Application. What I am trying to do is: 1. Create a simple report from a Firebird database using an ODBC connection 2. Need to compile and deploy to a production environment 3. How to set the data connection so it is can connect to the production database which is different to the dev database...this must be able to be done on the production system after compiling on the...
5
2268
by: samadams_2006 | last post by:
I'm having a problem in accessing a Microsoft Access Database in a VB.NET Web Application. It's so straight forward, I thought I'd walk you through all the details here: 1) I have a .NET Web Application called "Lesson18b" under "C:\Inetpub\wwwroot\Lesson18b". 2) I have one Web Form on this Lesson called "Form18b.aspx" 3) In this same Folder under Inetpub I have the Microsoft NorthWinds
0
7701
bartonc
by: bartonc | last post by:
#Boa:Dialog:DBConnectDialog import wx ##"""Given a set if login specs, create a dbServer instance and ## ensure that there is a valid, open connection to the database. ## If not, set the dbConnect to None. ## spec: dict(UserName=name, Password=pswd, ServerName=host) ## Allow names to be set with Default Holder. Consiter Dictionary ## or even a tuple? (name, pswd, host)"""
10
2090
by: Des | last post by:
I am trying to connect to a MySQL database on a windows server using ASP / ADODB I keep getting unable to display page http://www.desmond-otoole.co.uk/index.asp Any sugestions?
2
1120
by: kj | last post by:
I'm sure this is a simple, but recurrent, problem for which I can't hit on a totally satisfactory solution. As an example, suppose that I want write a module X that performs some database access. I expect that 99.999% of the time, during the foreseeable future, the database connection parameters will remain unchanged. The only exception that I envision for this would be during testing or debugging. Given all this, I am tempted to...
3
1483
by: Blarneystone | last post by:
Ok, I've got a simple access 97 db. named S_tracking.mdb It has two tables 1- Jobs 2- Employees I've set up the references: Imports System.Data.OleDb Imports System.IO Imports System.data
0
9722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10393
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10124
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.