CFanatic

Go Back   CFanatic > Programming > C# Programming

Join CFanatic Forum Now

MS Access DB access problem in C# topic posted under C# Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 10-23-2007, 05:38 AM
Junior Member
 
Join Date: Oct 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
tanvirtonu is on a distinguished road
| More
MS Access DB access problem in C#

Advertisement
Hello everybody,I m in new in C#. I gave password to my MS Access DB.Ms Access only requires password to set,it doesn't require user name.So I did it as they require.Now I made a very simple c# program which access the DB and retrieve some info.When I did it without giving the DB password,everything works well.But as I entered password in my DB,nothing works.This is supposed to be.Now,when I tried to add a new connection frm server explorer,firstly I set the name of the db provider,then next in the connection tab there are three fields-DB NAme,user name and password.Now that I know the DB name and the password I gave in my MS Access DB.But what to give in the user field?I didnt set any user name in my MS Access DB bcos it didnt require.If I set user name-"Admin", an error says-"cant open....work group information file is missing or opened exclusively by another user". I closed all(every other program) Access Db during adding new connection.Would anybody tell me how to solve it. I think I shud set the password different way in access.
Reply With Quote
  #2  
Old 09-08-2008, 02:31 AM
Junior Member
 
Join Date: Jul 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
praspam is on a distinguished road
| More
Re: MS Access DB access problem in C#

Public cn As ADODB.Connection
Public Function DBConnect() As Boolean

On Error GoTo OpenErr

Dim MSDatabase
Dim str As String

Set cn = New ADODB.Connection

cn.CursorLocation = adUseClient
str = "DBQ=" & App.Path & "\db.mdb;" + "DefaultDir=" & App.Path & ";" ' database name and directory
str = str + "Driver={Microsoft Access Driver (*.mdb, *.accdb)};"
str = str + "PWD=dbb;UID=admin;" ' password & user id
str = str + "DriverId%;FIL=MS Access;MaxBufferSize
48;MaxScanRows=8;PageTimeout=5;SafeTransactions=0; T hreads=3;UserCommitSync=Yes;"

cn.ConnectionString = str
cn.Open
DBConnect = True
Exit Function

OpenErr:

MsgBox "Error Opening " & MSDatabase & vbNewLine & Err.Description, vbCritical, "Open Database Error"
DBConnect = False

End Function
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
File I/O (Reading from a Random-Access File) VersEtreOuNe C++ Programming 0 02-12-2008 03:39 PM
Access 2007 file not accessible codeunlock C# Programming 0 04-29-2007 12:40 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 03:04 AM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board