How to connect sql server 2005 in asp.net with c#?


Imports System.Data.OleDb

Public con As New OleDbConnection("Provider=SQLOLEDB.1;Integrated
Security=SSPI;Persist Security Info=False;Initial Catalog=xyz;Data
Source=.\sqlexpress")

--------------******************************---------------------
here "xyz" means the project database name

and then try for connection

other wise follow these steps

1.first open empty notepad and save as "provider.udl" in your desktop
and it shows the imagelike a computer

2.just double click the icon select the provider tab

3.select "microsoft OLEDB for sql server" and click next

4.enter the server name as .\sqlexpress

5.select the database on the server (database name)

6.click on test connection this will tells the connectivity of the
database

7.if the testconnection succeedd then close and reopen with notepad

there we can find the
-------
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=xyz;Data Source=.\sqlexpress

copy this and paste on the application like

Public con As New OleDbConnection("Provider=SQLOLEDB.1;Integrated
Security=SSPI;Persist Security Info=False;Initial Catalog=xyz;Data
Source=.\sqlexpress")

No comments:

Post a Comment