954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How i Can connect Sql Server with ASP

Hi friend, i am trying to learn ASP but i face problem to connect ASP wtih
SQL Server.
Anyone help me.

Sushil ..

kapilver
Newbie Poster
5 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

Hi Sushil,

use this code to add data in a table using asp and sql server

<%
dim cn, rs
set cn=server.CreateObject("adodb.connection")
cn.Open "Provider=sqloledb;SERVER=localhost;DATABASE=your_database_neme;UID=your_database_login_id;PWD=your_database_login_password;"
set rs=server.CreateObject("adodb.recordset")
rs.open "Select * from table_name",cn,adOpenKeyset,adLockOptimistic
rs.addnew
rs(0) = "here_is_your_value_for_first_field"
rs(1) = "here_is_your_value_for_second_field"
rs.update
rs.close
%>
sandeep.kharat
Newbie Poster
3 posts since Jun 2006
Reputation Points: 10
Solved Threads: 0
 

Connect to SQL server with ASP needs ADODB connection.
This connection can extract data from database and insert data into database.
What problem do you face?

Zero13
Practically a Master Poster
624 posts since Jan 2009
Reputation Points: 120
Solved Threads: 139
 

Hi Sushil,

connect ASP wtih SQL Server.

<%
dim con, Rs
set con=server.CreateObject("adodb.connection")
con.Open "Provider=sqloledb;SERVER=localhost;DATABASE=database_name;UID=login_ID ;PWD=login_password;"
set Rs=server.CreateObject("adodb.recordset")

%>
Egypt web
Newbie Poster
19 posts since Aug 2009
Reputation Points: 12
Solved Threads: 0
 

i donot know about how to set drivers. plz tell me the name of drivers of sql

kiran gaba
Newbie Poster
1 post since May 2010
Reputation Points: 10
Solved Threads: 0
 

well i tried the above code to connect the SQL table, but it is always giving me an error and the webpage can not be displayed... any help please.. (btw i'm using SQL server 2008)

mohamed_r
Newbie Poster
1 post since May 2010
Reputation Points: 10
Solved Threads: 0
 

please guys help me i want code to connect my asp code to the MSSQL SERVER
Please help me

maips
Newbie Poster
2 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

Have you tried doing it through the designer hence creating the connection for you automatically

donnybrasco
Newbie Poster
2 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

It's doubtful. They evidently cannot even follow the most basic of instructions, search on their own for information that is available all over the net, or post detailed information about the problems they are experiencing.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You