i have to get began with being able to access a database with c#
please produce the easiest example possible!!
possibly a mysql database will be the easiest example?
please show me how you can connect with a mysql database and obtain data
If you wish to use MySQL, you may require a .Net Data Provider for MySQL or perhaps a MySQL ODBC driver.
Or you might install SQL Server Express Edition (free download).
Really there's an enormous insightful help there.
This can be a decent example of being able to access databases insinternet from first concepts.
Scott Guthrie authored a really nice (and lengthly) tutorial on data access using ASP.Internet.
To help keep things simple, you only have to consider the following:
- tutorial 1 - concentrate on option 2
- tutorial 2 - skip the part about advanced options
Guthrie provides code in VB.Internet. I'll rewrite the code in C# (that ought to go inside the scope from the Page_Load method under Default.aspx):
NorthwindTableAdapters.SuppliersTableAdapter suppliersAdapter = new NorthwindTableAdapters.SuppliersTableAdapter(); Northwind.SuppliersDataTable suppliers = suppliersAdapter.GetAllSuppliers(); foreach (Northwind.SuppliersRow supplierRow in suppliers) Response.Write("Supplier: " + supplierRow.CompanyName + "<br />");
Incidentally, the whole tutorial may be worth reading through.