| | |
database connection
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2007
Posts: 3
Reputation:
Solved Threads: 0
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 ......
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 ......
There is just two ways to live your life.
One is as though nothing is a miracle.
The other is as if everything is.
One is as though nothing is a miracle.
The other is as if everything is.
Try use 'Visual Web Developer'.. It is free of download from microsoft.com.. it has a wonderful GUI too. try the notch. GOod Luck
•
•
Join Date: Aug 2007
Posts: 11
Reputation:
Solved Threads: 0
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
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
![]() |
Similar Threads
- database connection(select ,insert query) within javascript function (JSP)
- Login Page Database connection to MSAccess (VB.NET)
- Problem with database connection (JSP)
- Database Connection in Visual Studio 2005 (ASP.NET)
- Visual C++, Database connection, please help (C++)
- ASP file with database connection problem (ASP)
- error due to accessing database connection using jsp (JSP)
Other Threads in the ASP.NET Forum
- Previous Thread: Collapsing/Expanding a grid view row in a ASP.net Web form
- Next Thread: Unable to save unicode characters into database
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax appliances application asp asp.net beginner box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox child class compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datalist deadlock deployment development dgv dialog dropdownmenu dynamic dynamically edit embeddingactivexcontrol feedback fileuploader fill findcontrol flash flv form forms grid gridview gudi homeedition hosting iis image javascript jquery list menu mssql multistepregistration nameisnotdeclared novell objects opera order problem ratings redirect registration relationaldatabases rotatepage search security select serializesmo.table sessionvariables silverlight smoobjects sql ssl tracking treeview typeof validatedate validation vb.net virtualdirectory vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment wizard xml xsl





