Connecting to access database using code

蓝咒 提交于 2020-01-24 19:34:09

问题


I am a student How to connect to access database using code ( not using wizard) and retrive values in the textbox in c# using visual studio 2008.

I have to extract 3 fields from the access database.

Do anybody know. Pl help.


回答1:


OleDbConnection is the standard class to query an Access database. Here's an example.




回答2:


Start by reading up on ADO.NET and then use the OleDb Data Provider. Once you have the values it should be trivial to put them into a text box.

Here is a good ADO.NET tutorial:

  • http://www.codersource.net/asp-net/ado-net/c-and-ado-net.aspx

And some good OLEDB info:

  • http://msdn.microsoft.com/en-us/library/6d9ew87b%28v=VS.71%29.aspx



回答3:


In addition: Get the "Visual C# 2010 Samples" from

http://code.msdn.microsoft.com/cs2010samples/Wiki/View.aspx?title=Home

and look at the

"OLEDB: Demonstrates how to use a Microsoft Access database from C# by creating a dataset and adding tables to it."

sample.



来源:https://stackoverflow.com/questions/4995333/connecting-to-access-database-using-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!