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.
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