| | |
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 |
Tag cloud for ASP.NET
.net 2.0 3.5 ajax alltypeofvideos appliances application asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class control countryselector dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit editing embeddingactivexcontrol feedback fileuploader fill findcontrol flash folder form gridview gudi iis image javascript list listbox login maps microsoft mobile mouse mssql nameisnotdeclared news novell numerical opera panelmasterpagebuttoncontrols parent problem project radio redirect registration relationaldatabases reportemail richtextbox rows schoolproject search security select sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visualstudio vs2008 web webapplications webdevelopment webprogramming webservice wizard xsl







