Solved

SQL server 2008R2 - how is it connected to a .NET application?

Posted on 2012-04-03
7
251 Views
Last Modified: 2012-04-18
Hello:

I want to understand in simple English, how do .NET applications and how do websites get (fetch) information from SQL server.

So there is the SQL server on one side, the front end application ,or website, on the other end, BUT how do they connect? what is the process?

Thank you.
0
Comment
Question by:noamco36
7 Comments
 
LVL 17

Assisted Solution

by:Anuroopsundd
Anuroopsundd earned 167 total points
ID: 37804698
most of the languages have inbuilt features to give user/Programmer functionality to connect to Databases.
so user just have to use these predefined functions and just pass the parameters  like username/Password/database server ip/type of database/Database name and others to make the connection.

ones the connection to the database is done we use sql command to query or write to the database.

Hope this helps...
0
 

Author Comment

by:noamco36
ID: 37804814
So does that mean that the initial connection set up is the responsibility on the application programmer?

If I am the DBA and am asked to connect an new application to my SQL server, and I dont know these inbuilt features/ Programmer functionalities, is there a work around with a third party application, or a driver setting etc?

Thanks.
0
 
LVL 6

Assisted Solution

by:Peter Kiprop
Peter Kiprop earned 83 total points
ID: 37804817
Hi noamco36,

if you are using VB.NET and ADO.NET then the code will be similar to the below

Public Function DBConnect() As SqlConnection
        Dim connectionstring As String
        connectionstring = "Persist Security Info=True;User ID=sa;Initial Catalog=DatabseName;Data Source=servername;password=Password"
        Dim cn As New SqlConnection(connectionstring)
        Return cn
End Function

    
Function GetAllContacts() As DataSet
        Dim cn As New SqlConnection
        Dim sql As String
        Dim ds As New DataSet
        Dim mytable As New DataTable("yourtablename")

        sql = "SELECT * FROM yourtablename"

    
        cn = DBConnect()
        cn.Open()
        Dim da As New SqlDataAdapter(sql, cn)
        da.Fill(ds, "yourtablename")
        'cn.Close() -- note: connection closed automatically by da.Fill

        Return ds
End Function

Open in new window

0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 17

Assisted Solution

by:Anuroopsundd
Anuroopsundd earned 167 total points
ID: 37804844
So does that mean that the initial connection set up is the responsibility on the application programmer?

Yes it is the application programmer to make the connection with the application. he may require DBA for the required infromation.

If I am the DBA and am asked to connect an new application to my SQL server, and I dont know these inbuilt features/ Programmer functionalities, is there a work around with a third party application, or a driver setting etc?
normally as a DBA you will know about your server information which is required.
Database type - SQL, ORacle ,MYsql
ip address of the database server
port on which database is running
username and password for connecting to database
0
 
LVL 42

Assisted Solution

by:EugeneZ
EugeneZ earned 166 total points
ID: 37805321
app using sql server drivers
and as per above posted example connection string

check the differemt variations @

http://www.connectionstrings.com/sql-server-2008
0
 
LVL 42

Assisted Solution

by:EugeneZ
EugeneZ earned 166 total points
ID: 37805324
check this presentation as well
Linking ASP.NET Page to SQL Server 2008R2 - Overview Visual Web Developer Express
http://www.youtube.com/watch?v=SyEV6oJI6Bw
0
 
LVL 25

Accepted Solution

by:
jogos earned 84 total points
ID: 37805472
Adding to theabove

The dba/security-responsible defines how connections may be made
- which logins and their permissions
- eventualy a specific application role http://msdn.microsoft.com/en-us/library/ms190998.aspx

The developer decides how deal whit that permission
- .Net Entity Framework http://msdn.microsoft.com/en-us/library/aa697427(v=vs.80).aspx
- other ORM-solutions
     http://en.wikipedia.org/wiki/Object-relational_mapping
     http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now