|
| |||||||||
| Tags: connect, database, programming, retrieve database |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| How to Connect Database and Retrieve it with the use of C#?
Hi friends I am a student of BSC.I.T. and wanted to know how to connect and retrieve database with the help of C#. We don't have that much in syllabus and want to know how to do it? If anyone has knowledge please help me. I am waiting for your reply. Just provide me steps or code so I can understand it. |
|
#2
| ||||
| ||||
| Re: How to Connect Database and Retrieve it with the use of C#?
Hi, you can use following code to connect database in c# Code: 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();
// Just insert here your code to process data
catch (Exception caught)
{
MessageBox.Show(caught.Message);
}
finally
{
conn.Close();
}
} |
|
#3
| |||
| |||
| Re: How to Connect Database and Retrieve it with the use of C#?
Hi friend, I am also facing same problem as you, I have tried to search this on net, but not get anything regarding this. If you find something regarding this then suggest me also. I am waiting for you to reply me. I will search for this and if find something then I will give it to you. Just give me if you got earlier that me. Just post on this forum. I will take it as I am always using this forum for my queries. |
|
#4
| ||||
| ||||
| Re: How to Connect Database and Retrieve it with the use of C#?
Hi, Just use following for your making connection as a code, I think this would help you. Code: database. conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source=AccessFile.mdb"; Visual Basic: Code: 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 Code: 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();
} Code: 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();
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to Connect Database and Retrieve it with the use of C#?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to connect PHP to mySQL Database | Nathen | Tips & Tweaks | 2 | 17-07-2011 04:49 AM |
| Using Ajax to Retrieve Data from a MySQL Database | warthogweb | Software Development | 1 | 19-11-2010 10:46 PM |
| How to connect ASP to different database | Elijah2010 | Software Development | 5 | 16-02-2010 12:01 AM |
| how to connect VB6 to database | WILTON | Software Development | 3 | 08-12-2009 04:26 AM |
| Connect to Oracle database using VB 6.0 | Ariadne | Software Development | 2 | 19-01-2009 06:09 PM |