| | |
connection string of SqlConnection
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: May 2007
Posts: 266
Reputation:
Solved Threads: 3
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?
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
•
•
Join Date: Jul 2007
Posts: 2
Reputation:
Solved Threads: 1
please follow following link
http://www.codeproject.com/cs/databa...ssInCSharp.asp
or write following code
http://www.codeproject.com/cs/databa...ssInCSharp.asp
or write following code
C# Syntax (Toggle Plain Text)
using System; using System.Data; using System.Data.OleDb; public class Test{ public static void Main() { string source = "Provider=Microsoft.JET.OLEDB.4.0;" + "data source=""C:\\Winnt\\Profiles\\Administrator\\Personal\\db2.mdb string command="SELECT Name, Assets FROM Bank_customer_data"; OleDbCommand mCommand = new OleDbCommand(); OleDbConnection mConnection=new OleDbConnection(source); mConnection.Open(); mCommand.ActiveConnection=mConnection; mCommand.CommandText=command; OleDbDataReader mReader; mCommand.Execute(out mReader); // Use Read to read data line by line. while (mReader.Read()) { //The data is extracted with the methods GetString and GetInt32 Console.WriteLine(mReader.GetString(0) + ":" + mReader.GetInt32(1)); } // Close the Reader when done. mReader.Close(); // Close the connection when done. mConnection.Close(); } }
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.
Dont forget to spread the reputation to those that deserve!
![]() |
Similar Threads
- Connection String (Visual Basic 4 / 5 / 6)
- Connection String (MS Access and FileMaker Pro)
- connection string (ASP.NET)
- Dynamic Connection String Using ADO (Visual Basic 4 / 5 / 6)
- Prblem with sql sever connection (ASP.NET)
Other Threads in the C# Forum
- Previous Thread: How to make C# application quit
- Next Thread: workink with list box in GUI
| Thread Tools | Search this Thread |
.net access algorithm array barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom customactiondata database datagrid datagridview dataset date/time datetime datetimepicker degrees development dll draganddrop drawing encryption enum event excel file filename files form format forms function gdi+ gis gtk hash httpwebrequest image index input install java label list listbox mandelbrot math mouseclick mysql operator outlook2003 path photoshop picturebox pixelinversion pixelminversion post programming radians regex remote remoting richtextbox server sleep socket sql statistics stream string table tables tcp text textbox thread time timer tutorial update usercontrol usercontrols validation visualstudio webbrowser webcam wia windows winforms wpf xml





