Search : in
By :

Database connect and retrieve in c#

Last answer on Sep 3, 2009 10:29:24 am BST 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 :
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...
Visual FoxPro ShowVisual FoxPro Visual FoxPro (VFP) is a very powerful tool marketed by Microsoft since 1995. It includes a programming language, an engine for relational database and an integrated development environment (IDE), which allows developers...
Download MicroOLAP Database Designer for MySQL ShowMicroOLAP Database Designer for MySQL is a powerful development system for database visual modeling, modification, maintenance and reverse engineering in an easy and powerful way. MicroOLAP Database Designer for MySQL also allows to publish or to...
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...
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...
S-video (Y/C) ShowThe S-Video standard The S-Video standard (for "Sony Video"), sometimes called Y/C, is a video transmission mode with separate components using different cables to carry information regarding luminance (luminosity) and chrominance (colour). An S...

1

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

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