i need help in code of connecting from asp.net 2005 to access

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2008
Posts: 6
Reputation: nada fouad is an unknown quantity at this point 
Solved Threads: 0
nada fouad nada fouad is offline Offline
Newbie Poster

i need help in code of connecting from asp.net 2005 to access

 
0
  #1
Feb 16th, 2009
i want to connect asp.net 2005 with access .
now i need for the code do do this connection
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 34
Reputation: manoj_582033 is an unknown quantity at this point 
Solved Threads: 0
manoj_582033 manoj_582033 is offline Offline
Light Poster

Try This

 
0
  #2
Feb 16th, 2009
Create a variable Like x
Then
x="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\office.mdb"
Note :C:\Program Files\office.mdb By replacing it put your datasource And then try this
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 6
Reputation: nada fouad is an unknown quantity at this point 
Solved Threads: 0
nada fouad nada fouad is offline Offline
Newbie Poster

Re: i need help in code of connecting from asp.net 2005 to access

 
0
  #3
Feb 17th, 2009
thnx for reply

what about the full code & the veriables when i want to do insert and the code to execute the query ???
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: i need help in code of connecting from asp.net 2005 to access

 
0
  #4
Feb 17th, 2009
Go to http://www.connectionstrings.com
It is your friend. Bookmark it.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,200
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 571
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: i need help in code of connecting from asp.net 2005 to access

 
0
  #5
Feb 17th, 2009
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.

  1. public static string BuildAccessConnectionString(string Filename, string Username, string Password, string DatabasePassword)
  2. {
  3. return string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='{0}';User Id={1};Password={2};Jet OLEDB:Database Password={3};",
  4. Filename.Replace("'", "''"),
  5. Username,
  6. Password,
  7. DatabasePassword);
  8. }
  9. public static string BuildAccess2007ConnectionString(string Filename, string DatabasePassword)
  10. {
  11. return string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='{0}';Persist Security Info=False;Jet OLEDB:Database Password={1};",
  12. Filename.Replace("'", "''"),
  13. DatabasePassword);
  14. }
  15. private void simpleButton3_Click(object sender, EventArgs e)
  16. {
  17. string connStr = BuildAccessConnectionString(@"C:\data\CustList01.mdb", string.Empty, string.Empty, string.Empty);
  18. DataTable result = new DataTable();
  19. using (OleDbConnection conn = new OleDbConnection(connStr))
  20. {
  21. conn.Open();
  22. using (OleDbCommand cmd = new OleDbCommand(@"Select * From [CustList01]", conn))
  23. {
  24. using (OleDbDataReader dr = cmd.ExecuteReader())
  25. {
  26. result.Load(dr);
  27. }
  28. }
  29. conn.Close();
  30. }
  31. //Work with table
  32. MessageBox.Show(result.Rows.Count.ToString());
  33. }
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC