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
Printable View
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
there would be no difference in coding database access in a console app or a windows app.
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?
ok well I didnt know you meant the lazy way! :D
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. :)
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
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();
}
}