|
-
May 6th, 2002, 09:48 PM
#1
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
-
May 6th, 2002, 10:32 PM
#2
there would be no difference in coding database access in a console app or a windows app.
-
May 6th, 2002, 10:41 PM
#3
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?
-
May 7th, 2002, 08:41 AM
#4
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.
-
May 7th, 2002, 08:49 AM
#5
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
-
May 7th, 2002, 09:00 AM
#6
-
May 7th, 2002, 02:04 PM
#7
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|