Connection String Used In ASP And ASP.NET Using DSN

As we know that there are two ways to connect with database one is using DSN and second one is without DSN. Today I will provide you guideline how to establish connection with MS ACCESS database using DSN. To establish connection with database using DSN first of all you have to create DSN of database which you want to use in your application, like DSN for ACCESS, SQL, etc


For giving you perfect idea on how to work with DSN I am giving you full source code which you can use in your application but be sure that code is written for ASP.


To start coding using asp first of all you have to declare Scriplet tag which is the first line of ASP coding which you can see below




set objcon=server.CreateObject("ADODB.Connection")


objcon.Open "DSN=dsnname"

Set RS2 = Server.CreateObject("Adodb.RecordSet")




rs2.CursorType =1

query="select nm from Table" query

                        if rs2.recordcount > 0 then

                        do while not rs2.eof

                        Variable = rs2("fieldname")




                        end if                                                   


‘Don’t forget to write below given lines


Set objcon=Nothing


(Posted By Aden)

Sign up for a newsletter