Results 1 to 7 of 7

Thread: console Application and databases

  1. #1
    dmartin17
    Guest

    console Application and databases

    Is there a simple way to include a database in a console application? I was hoping for an easy way like there is when you do a windows application but i can't find it.


    Thanks

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    there would be no difference in coding database access in a console app or a windows app.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    dmartin17
    Guest
    ok well there seems to be for me. For a windows application I would drag the connection onto the form and it generates code for me automatically. I can't do this with a console form.

    any help?

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    ok well I didnt know you meant the lazy way!

    just kidding.

    You will need to learn how to code database connections probably then instead of just relying on drag drop. Good thing to do anyway.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5
    dmartin17
    Guest
    thats fine. but instead of telling me wht i need to do can you show me?

    btw ive kind od figured it out, update/insert commnads gave me tricks

  6. #6
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  7. #7
    Hyperactive Member thinktank2's Avatar
    Join Date
    Nov 2001
    Location
    Arctic
    Posts
    272
    Here is something I made several weeks before, fairly enough to get you started..

    PHP Code:
    using System;
    using System.Data.OleDb;

    class 
    dbtest
    {
        public static 
    void Main()
        {
            
    string ConnStr "Provider=Microsoft.Jet.OLEDB.4.0;" ;
            
    ConnStr += "Data Source=C:\\My Documents\\test.mdb;" ;

            
    OleDbConnection Conn = new OleDbConnection(ConnStr);
            
    Conn.Open();

            
    OleDbCommand Cmd = new OleDbCommand("Select * from Sample",Conn);

            
    OleDbDataReader dbReader Cmd.ExecuteReader();

            while(
    dbReader.Read())
            {
                
    Console.Write(dbReader["Name"].ToString() + "\t");
                
    Console.Write(dbReader["Age"].ToString() + "\t");
                
    Console.WriteLine(dbReader["Email"].ToString());
            }
            
            
    Console.ReadLine();
        }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width