ASP.NET using C# - How to Connect/Retrieve in database to web a

March 2017

Some people may be carrying out projects in ASP.NET and they may need help with connecting their database with ASP.NET. Likewise with retrieving in database to web application. A specific sequence must be followed with regards to the database and the retrieving process. Some programming knowledge is needed to able to carry out the steps. The answer below should provide the answers to the issues just mentioned.


I am doing my project work, and I have a problem. My project is in but I don't know how to connect the database in using c# and how to retrieve in database to web application.


Notice this line:
-> database. conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data source= @"path AccessFile.mdb";

It should be:
-> database. conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source=AccessFile.mdb";

Other Connection String Sample.

Visual Basic]     
Public Sub CreateSqlConnection()     
Dim myConnection As New SqlConnection()     
myConnection.ConnectionString = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30"     
End Sub 'CreateSqlConnection     

public void CreateSqlConnection()     
SqlConnection myConnection = new SqlConnection();     
myConnection.ConnectionString = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30";     

void CreateSqlConnection()     
SqlConnection* myConnection = new SqlConnection();     
myConnection->ConnectionString = S"Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30";     


Thanks to Wicket for this tip on the forum.


Published by aakai1056.
This document, titled "ASP.NET using C# - How to Connect/Retrieve in database to web a," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (