Results 1 to 4 of 4

Thread: db connectivity

  1. #1
    Junior Member
    Join Date
    Sep 2007
    Answers
    1

    db connectivity

    Hi
    i have three fields
    emp name
    empid
    emp dept
    now i want to connect to acess db and want to populate the db with new records


  2. #2
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: db connectivity

    So whats the problem then ?


  3. #3
    Junior Member
    Join Date
    Sep 2007
    Answers
    7

    Re: db connectivity

    It is similar to any other DBMS like SQL.
    Use ODBCConnection and OdbcReader .In Connection String= ";dbq="Pathname of file;dsn=access files ";


  4. #4

    Re: db connectivity

    see the sample below,

    string dbConnString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\test.mdb";
    OleDbConnection dbConn = new OleDbConnection(dbConnString);
    OleDbCommand dbCommand = new OleDbCommand();
    dbCommand.Connection = dbConn;
    dbConn.Open();

    dbCommand.CommandType = CommandType.Text;
    dbCommand.CommandText = "Select * from Employee";
    OleDbDataReader dr = dbCommand.ExecuteReader();
    while (dr.Read() == true)
    {
    Console.WriteLine(dr["uid"].ToString() + ":"+ dr["uname"].ToString() + ":" + dr["udept"].ToString());
    }
    dbConn.Close();


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact