| | |
i need help in code of connecting from asp.net 2005 to access
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2005
Posts: 483
Reputation:
Solved Threads: 19
Go to http://www.connectionstrings.com
It is your friend. Bookmark it.
It is your friend. Bookmark it.
There are two functions for generating the conn string depending on the version of access, which can be determined by the file extension or various other ways.
c# Syntax (Toggle Plain Text)
public static string BuildAccessConnectionString(string Filename, string Username, string Password, string DatabasePassword) { return string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='{0}';User Id={1};Password={2};Jet OLEDB:Database Password={3};", Filename.Replace("'", "''"), Username, Password, DatabasePassword); } public static string BuildAccess2007ConnectionString(string Filename, string DatabasePassword) { return string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='{0}';Persist Security Info=False;Jet OLEDB:Database Password={1};", Filename.Replace("'", "''"), DatabasePassword); } private void simpleButton3_Click(object sender, EventArgs e) { string connStr = BuildAccessConnectionString(@"C:\data\CustList01.mdb", string.Empty, string.Empty, string.Empty); DataTable result = new DataTable(); using (OleDbConnection conn = new OleDbConnection(connStr)) { conn.Open(); using (OleDbCommand cmd = new OleDbCommand(@"Select * From [CustList01]", conn)) { using (OleDbDataReader dr = cmd.ExecuteReader()) { result.Load(dr); } } conn.Close(); } //Work with table MessageBox.Show(result.Rows.Count.ToString()); }
![]() |
Similar Threads
- Simple ASP.Net Login Page using C# (C#)
- How To Create Login Page in ASP.NET (ASP.NET)
- FAO: Paladine (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: not sure of codes
- Next Thread: How to deploy SharePoint website or webapplication?
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions control css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iframe iis javascript listbox login microsoft mono mouse mssql multistepregistration news novell numerical objects opera panelmasterpagebuttoncontrols radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers







