How would u connect to database using .NET?

Answers were Sorted based on User's Feedback



How would u connect to database using .NET?..

Answer / rajeev ranjan lall

SqlConnection conn = new SqlConnection("Data
Source=ServerName;Initial Calalog=DatabaseName;User
ID=username;Password=password")

Is This Answer Correct ?    15 Yes 1 No

How would u connect to database using .NET?..

Answer / ramakrishna

sqlconnection cn =new sqlconnection("uid=sa;pwd=sa;data
source=servername;database=databasename");

Is This Answer Correct ?    8 Yes 2 No

How would u connect to database using .NET?..

Answer / vivek

using Connection object
SqlConnectin cn=new SqlConnection();
from .net we can connect to any backend with middlleware
and direct connections.
middleware means ODBC,OleDb,ISAM etc.
we can directly connect to Sqlserver and Oracle
we can connect to sql server in 4 ways
1)direct connection
2)ODBC way
3)OleDb way
4)Express way
for oracle we can connect in 3 ways.
1)direct connection
2)ODBC way
3)OleDb way

Is This Answer Correct ?    0 Yes 0 No

How would u connect to database using .NET?..

Answer / lalitkumar

sqlconnection con=new
sqlconnection("@server=.sqlexpress;database=master;trusted_connection=yes")

Is This Answer Correct ?    0 Yes 0 No

How would u connect to database using .NET?..

Answer / rathish

go to project->add reference->adodb

DECLERATION

Dim con As ADODB.Connection
Dim cmd As ADODB.Command
Dim str, cnstr, sql As String
Dim cn As OleDb.OleDbConnection


FORM LOAD

Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
con = New ADODB.Connection
con.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\new folder\employee.mdb")
End Sub

in the source you have to give the path of ur file name..

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More ADO.NET Interview Questions

What is Pooling? what is data pooling? what is sql pooling?

3 Answers   TCS,


How you will set the datarelation between two columns?

3 Answers  


What are relation objects in dataset and how & where to use them?

1 Answers  


Features and disadvantages of dataset?

2 Answers   CarrizalSoft Technologies, Infosys, Microsoft, Sampath Software,


What does ado stand for in ado.net?

0 Answers  






Which one of the objects is a high-level abstraction of the connection and command objects in ado.net?

0 Answers  


Explain the advantages and disadvantages of using datalist?

0 Answers  


Which parameter of ConnectionString is used to specify the name of the database?

0 Answers  


how Sequence to connect and retrieve data from database using dataset?

0 Answers  


What?s the role of the DataReader class in ADO.NET connections?

7 Answers   Honeywell, Ksb,


About ADO and its objects ?

1 Answers   DELL,


What is the default provider in ado.net?

0 Answers  


Categories