944,188 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 3002
  • ASP.NET RSS
Jul 23rd, 2007
0

database connection

Expand Post »
Hi, i am new to .net technologies. i want to startwith a database conn. how to connect with sql server database with my asp.net default page. please explan.

samy
Reputation Points: 10
Solved Threads: 0
Newbie Poster
samycbe is offline Offline
4 posts
since Jul 2007
Jul 23rd, 2007
0

Re: database connection

first u have to imports the namespace

imports system.data.sqlClient

then create the object of connection class
dim conn as new sqlconnection("server=localhost;uid=sa;pwd=123;database=northwind")

then create a object of data adapter
dim objAdap as new sqlDataAdapter("select * from products",conn)

then u have to create dataset object
dim ds as new dataset

now u have to used the fill method of adapter class
objAdap.fill(ds,"products")
now create one datagrid object and assign the dataset values like this

datagrid1.datasource=ds

and the last thing u have the bind the values to datagrids

datagrid1.databind()

and ur connection is complete ......
Reputation Points: 10
Solved Threads: 0
Newbie Poster
abdul4484 is offline Offline
3 posts
since Jul 2007
Jul 24th, 2007
0

Re: database connection

Did you try using the google?

Try this link
Reputation Points: 347
Solved Threads: 13
Practically a Posting Shark
arjunsasidharan is offline Offline
812 posts
since Aug 2006
Aug 12th, 2007
0

Re: database connection

Try use 'Visual Web Developer'.. It is free of download from microsoft.com.. it has a wonderful GUI too. try the notch. GOod Luck
Reputation Points: 11
Solved Threads: 0
Junior Poster in Training
Hellodear is offline Offline
53 posts
since Feb 2007
Aug 14th, 2007
0

Re: database connection

Hi,

The connection object establishes a connection to the database. Two of the most common Connection objects used are OleDbConnection and SqlConnection. If we are querying a SQL Server database, we should use the SqlConnection class. The ConnectionString property of the Connection object is used to provide information such as data source and database name, that is used to establish the connection with the database.

Required Connection String Fields

For every connection string, we must specify the following.

Dim myConnection As SqlConnection = New SqlConnection(“Data Source=SYS1;Integrated Security=SSPI;Initial Catalog=FinAccounting”)

The Provider:

When we use a SqlConnection, you don’t have to specify a provider, because the class talks directly to the SQL Server API.

If we are using the OLE DB provider, the connection string is as follows:

Dim myConnection As SqlConnection = New SqlConnection(“Data Source=SYS1;Integrated Security=SSPI;Initial Catalog=FinAccounting; Provider=MSDAORA”)

The above string can be used to connect to an Oracle database through the MSDAORA OLE DB provider.

The Data source:

The Datasource is the location of the database or database server. For example, if your database server is on the same machine as your development environment, you could use the name localhost. If the database is remote, we must provide the name of the database server(SYS1 as mentioned above).

The Initial Catalog:

A catalog is the same thing as a database, so initial catalog refers to the name of the database we want to query. Examples are Northwind and FinAccounting.

Security information:

We can pass an explicit user ID and password, or we can use the Integrated Security setting to specify that the connection is secure. The Integrated Security field accepts one of three values: True, False, or SSPI(Security Support Provider Interface). SSPI is essentially a buffer between your application and the various security protocols used by data and service providers, such as

databases or web servers. If integrated security is not supported, the connection must indicate a valid user and password combination. For a newly installed SQL Server database, the sa (System administrator) account is present without a password as shown below.

Dim myConnection As SqlConnection = New SqlConnection(“Data Source=SYS1;Integrated Security=SSPI;Initial Catalog=FinAccounting; user id=sa;password=”

Connecting Sql server Database from ASP.Net page
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vbsqluser is offline Offline
11 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Collapsing/Expanding a grid view row in a ASP.net Web form
Next Thread in ASP.NET Forum Timeline: ASP.NET menu control is not working with IE6.0





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC