Search : in
By :

Database connect and retrieve in c#

Last answer on Nov 10, 2009 9:11:55 am GMT raja, on May 20, 2009 7:39:43 am BST 
 Report this message to moderators

Hello,
I am ilayaraja doing my project work,i have one problem
my project doing in asp.net
but i don't know how to connect the database in asp.net using c# and how to retrieve in database to web application .
please give the answer my question, urgently.

Configuration: Windows Vista
Firefox 3.0.10

Best answers for « database connect and retrieve in c# » in :
ASP.NET using C# - How to Connect/Retrieve in database to web a Show ASP.NET using C# - How to Connect/Retrieve in database to web application Issue Solution Note Issue I am doing my project work, I have one problem My project doing in asp.net but I don't know how to connect the database in asp.net...
Connect a database (MDB) to excel Show[VBA] Connecting a database (MDB) to excel Below is a tips of how to connect an Access database (MDB) in an application excel Add reference Microsoft DAO object librairy X.X In a general module (eg Module1) paste the code below...
Connecting to Oracle via php ShowConnecting to Oracle via php Settings Requirements Example of code Settings Below is an article based on an example of connection to an Oracle database through a php script. However it is not designed to configure your oracle...
[Windows XP] Repairing the network connection using command line Show[Windows XP] Repairing the network connection using command lines Under Windows XP there is a small feature allowing you to repair a network connection. Go to the Network Connections options in Control panel (Control Panel / Network...
ODBC ShowWhat is ODBC? ODBC stands for Open Database Connectivity. This is a Microsoft-defined format for communicating between Windows database clients and consumer DBMSs. The ODBC managier can be found in Windows 3.1 and 9x. In Windows 95 and 98, it is...
Introduction - Databases ShowWhat is a database? A database (abbreviated DB) is an entity in which data can be stored in a structured manner, with as little redundancy as possible. Different programs and different users must be able to use this data. Therefore, the concept of...
Databases - Using forms ShowUsing forms In order to use databases, the user must be provided with an interface that allows him or her to view data based on certain criteria. There is a tool for this: forms. A form is an interface with components for displaying, entering, or...

1

epsiman, on May 20, 2009 8:54:44 am BST
  • +8

The code is

public void ConnectToAccess()
{
System.Data.OleDb.OleDbConnection conn = new
System.Data.OleDb.OleDbConnection();
database. conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data source= @"path \AccessFile.mdb";
try
{
conn.Open();
// Insert code to process data.
}
catch (Exception caught)
{
MessageBox.Show(caught.Message);
}
finally
{
conn.Close();
}
}

Reply to epsiman

2

anon, on Jul 13, 2009 8:22:31 pm BST
  • +3

Missing a double quote somewhere

Reply to anon

3

jax, on Aug 30, 2009 5:39:34 am BST
  • +2

Are you sure is this correct? I'll try to do this my self and send a reply to if positive.

Reply to jax

4

Wicket, on Sep 3, 2009 10:29:24 am BST
  • +5

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

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"
myConnection.Open()
End Sub 'CreateSqlConnection

[C#]
public void CreateSqlConnection()
{
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30";
myConnection.Open();
}

[C++]
public:
void CreateSqlConnection()
{
SqlConnection* myConnection = new SqlConnection();
myConnection->ConnectionString = S"Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30";
myConnection->Open();
}

Reply to Wicket

5

 pp, on Nov 10, 2009 9:11:55 am GMT

Kya re itana bhi nahi aata tuzko..
kyon programming me aaya.

Reply to pp