943,947 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 20715
  • C# RSS
Jul 9th, 2007
0

connection string of SqlConnection

Expand Post »
i am trying to connect to an MS Access database but i am new to C#. I have looked at, amongst others, Paladin's response to dark omen about connecting to a database and since i have connected to a database before in Visual Basic most of it makes sense to me.

However i do not understand the argument list for the connection string of the SqlConnection object's SqlConnection constructor. On various info sources the arg list for the constructor seems to differ slightly so i assume that some arguments are optional. can someone please tell me what the bare minimum of arguments are for connecting to an MS Access database on a local pc and what each argument means?
Last edited by quintoncoert; Jul 9th, 2007 at 8:29 am. Reason: ommited information
Similar Threads
Reputation Points: 160
Solved Threads: 3
Posting Whiz in Training
quintoncoert is offline Offline
266 posts
since May 2007
Jul 9th, 2007
0

Re: connection string of SqlConnection

please follow following link
http://www.codeproject.com/cs/databa...ssInCSharp.asp

or write following code
C# Syntax (Toggle Plain Text)
  1. using System;
  2. using System.Data;
  3. using System.Data.OleDb;
  4.  
  5. public class Test{
  6. public static void Main()
  7. {
  8. string source = "Provider=Microsoft.JET.OLEDB.4.0;" + "data source=""C:\\Winnt\\Profiles\\Administrator\\Personal\\db2.mdb
  9. string command="SELECT Name, Assets FROM Bank_customer_data";
  10. OleDbCommand mCommand = new OleDbCommand();
  11. OleDbConnection mConnection=new OleDbConnection(source);
  12. mConnection.Open();
  13. mCommand.ActiveConnection=mConnection;
  14. mCommand.CommandText=command;
  15. OleDbDataReader mReader;
  16. mCommand.Execute(out mReader);
  17. // Use Read to read data line by line.
  18. while (mReader.Read())
  19. { //The data is extracted with the methods GetString and GetInt32
  20. Console.WriteLine(mReader.GetString(0) + ":" + mReader.GetInt32(1));
  21. }
  22. // Close the Reader when done.
  23. mReader.Close();
  24. // Close the connection when done.
  25. mConnection.Close();
  26. }
  27. }
  28.  
Reputation Points: 10
Solved Threads: 1
Newbie Poster
kailash.kandpal is offline Offline
2 posts
since Jul 2007
Jul 10th, 2007
0

Re: connection string of SqlConnection

http://www.connectionstrings.com/ the best damn link hands down in finding the right string to use to connect to a given array of database types.
Reputation Points: 152
Solved Threads: 39
Master Poster
Killer_Typo is offline Offline
778 posts
since Apr 2004
Nov 12th, 2010
0
Re: connection string of SqlConnection
how to store data from sql to msAccess using C#
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vkmaurya5785 is offline Offline
3 posts
since Nov 2010
Nov 12th, 2010
0
Re: connection string of SqlConnection
plz tell me anybody how to store data from sql to msAccess using C#
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vkmaurya5785 is offline Offline
3 posts
since Nov 2010
Nov 12th, 2010
0
Re: connection string of SqlConnection
plz tell me tell me tell me how to store data from sql to msAccess using C#
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vkmaurya5785 is offline Offline
3 posts
since Nov 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Array times two
Next Thread in C# Forum Timeline: about image source





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC