Database Access

Get connection to database access with C#

Page 1 of 1

3 Replies - 1386 Views - Last Post: 04 January 2010 - 02:47 AM Rate Topic: -----

#1 Ohood  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 03-January 10

Database Access

Post icon  Posted 03 January 2010 - 10:32 PM

Hi , I have aproblem with this code it doesn't work , I want to read and write data in database access by using web developer(C#)

 
 //  class OleDbConnectionAccess
	//			{
   //  public static void Main()
	//   {

	String connectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\db2.mdb";
			OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);

			OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();
			myOleDbCommand.CommandText = "SELECT FirstName, LastName, Password " + "FROM Person ";
			myOleDbConnection.Open();
			OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();
			myOleDbDataReader.Read();
			Console.WriteLine("myOleDbDataReader[\"FirstName\"] = " + myOleDbDataReader["FirstName"]);
			Console.WriteLine("myOleDbDataReader[\"Password\"] = " + myOleDbDataReader["Password"]);

		   

			myOleDbDataReader.Close();
			myOleDbConnection.Close();
	  //}
 // }
	
}



Admin Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)

Is This A Good Question/Topic? 0
  • +

Replies To: Database Access

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Database Access

Posted 03 January 2010 - 11:07 PM

First, can you be a little less vague than "It does not work", what does not work? What does it do versus what you need it to do? Do you receive any errors, if so what are they? When asking for help with code you need to be way more specific before any kind of assessment can be made, simply stating "IT does not work" and expecting others to figure out what you mean just doesn't work.

Second, this is more of a C# question rather than a database question, so for that reason I am moving this to the C# forum.
Was This Post Helpful? 0
  • +
  • -

#3 Ohood  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 03-January 10

Re: Database Access

Posted 04 January 2010 - 01:51 AM

Hi

Thanks for this comments ,actally this is the first time I write here and I don't know if you understand my question or not. I will be mre specifaic next time.


Ok about my question it doesn't give my ay error but it doesn't save or read from database access?
I solve it and know read from database access. And know I want to write and save the data in access and print the result in the table???
Was This Post Helpful? 0
  • +
  • -

#4 olibenu  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 45
  • View blog
  • Posts: 537
  • Joined: 31-December 08

Re: Database Access

Posted 04 January 2010 - 02:47 AM

maybe try an sql tutorial, w3schools maybe
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1