Connecting with MSDE to MS Access database

Hi,

I must admit i'm a bit of a noob so go easy please!

I've been trying to connect from a C# form to a MS access database through MSDE. I've been trawling the internet for hours and can't solve the problem.

Here's my method:

In .Net i've opened server explorer, right clicked Data Connections and selected add connection, opening 'Data Link Properties'.

I've inputted Server Name 'WORK'
Put in user name 'sa'
password 'hello'

At this point the test connection works.

I then want to select the database. I'm given 4 options, master, model, msdb, tempdb.
Not sure what they are for. Could someone explain

Anyway  I need to connect a database, stored on the same machine in My Documents called YLCdb.mdb

If i try entering the file name, or the path & filename i now get an error when i try a test connection:

'Test connection failed because of an error in intitializing provider. Cannot open database requested in login 'YLCdb'. Login fails.

Any help will be much appreciated.




Answer this question

Connecting with MSDE to MS Access database

  • MPRamkumar

    Hi,


    BTW, if your using VC# Express Beta 2 you could graphically modify your database by using the Database Explorer and connecting to your local instance of SQLServer Express. Once you made the connection, just tinker around to be able to add new tables...



    cheers,



    Paul June A. Domag

  • Abnerian

    Hi,


    It seems you got confused between ACCESS databases (mdb) and SQL Server (MSDE)...
    When you want to connect to a access database,
    This is done in the datasources...

    1. create a new connection.
    2. Under the DataSource press the change button.
    3. Select Microsoft Access Database File..
    4. Click Ok and specify the location of the mdb...

    to your other questions, the

    I then want to select the database. I'm given 4 options, master, model, msdb, tempdb.
    Not sure what they are for. Could someone explain


    * well this 4 options as you call it are the default databases inside SQL Server, these are also termed as system databases...

    the problem lies in your datasource, you are trying to access an ACCESS database using SQLServer as its provider... you must use the specified provider depending on your selected database...


    BTW, MSDE (Microsoft Desktop Engine) is also a database server like ACCESS but is far more effective... Try using that instead...




    cheers,


    Paul June A. Domag

  • Simon Temby

    Hi,


    Here's a link that might be helpful...
    How to: Connect to a Database 
    http://www.codeproject.com/aspnet/adodotnet.asp





    cheers,


    Paul June A. Domag

  • amar

    Hi,

    Indeed, you can create table, views, triggers and a lot more database objects in MSDE. Recently Microsoft released SQLServer Express Beta 2 which would be a replacement for MSDE. Sad to say, currently it has no graphical way to create tables and relationships. You must do it manually using T-SQL commands. eg


    CREATE TABLE sample (
             id nvarchar(20),
             fname nvarchar(10)
    )

    GO


    I know this is a little bit native. The only graphical tool available is the enterprise manager of SQLServer 2000 (Drag-drop functionalities on creating relationships just like ACCESS)...
    But if you still want to learn, Get a Copy of SQLServer Express and Express Manager...
    http://lab.msdn.microsoft.com/express/sql/
    Also, download the Books On Line(BOL) for some T-SQL Language Reference...

     

    cheers,

     

    Paul June A.



  • Calvin Ho

    Would you give an example about how to connect to a local sql database in c# I am writing a web service in c# but I don't know how to code. It seems that I can't use those handy visual components in Windows Form.
  • faf38

    Thanks Paul, much appreciated.

    As the end you said
    "BTW, MSDE (Microsoft Desktop Engine) is also a database server like ACCESS but is far more effective... Try using that instead..."

    Could you please explain how i might do that in a little more detail Does this mean you can set up tables/relationships etc in MSDE if so how

    Thanks again.

  • Connecting with MSDE to MS Access database