Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access ASP
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 28th, 2005, 12:50 AM
Authorized User
 
Join Date: Jul 2005
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Inserting data into Sqlserver

Hi,
can any one help me out for inserting data into SQL SERVER From asp page using stored procedure.
I am having a text boxes in my ASP PAGE,
If i enter data in the textboxes it should be inserted into the table in SQL SERVER.


Thanks in Advance,
Ram.

Reply With Quote
  #2 (permalink)  
Old July 28th, 2005, 03:23 PM
Authorized User
 
Join Date: Mar 2005
Location: arima, West Indies, Trinidad and Tobago.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to arimakidd
Default

Hi Ram
See if the following code helps. Just remember because you are using SQL instead of Access as a datastore the dsn-less connection line will change. And Instead of stating the SQL Statement you would just put your "procedure". I am assuming alot by just giving you this code and I hope you understand it. Just remember use your procedure instead of the SQL commands and you will change the line for the dsn-less connection, don't have it on me right now but if you need it let me know and i'll post it. Here goes:
Code:
<%
'Dimension variables
Dim adoCon              'Holds the Database Connection Object
Dim rsAddComments   'Holds the recordset for the new record to be added
Dim strSQL               'Holds the SQL query to query the database

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("guestbook.mdb")

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"

'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblComments.Name, tblComments.Comments FROM tblComments;"

'Set the cursor type we are using so we can navigate through the recordset
rsAddComments.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsAddComments.LockType = 3
'Open the recordset with the SQL query
rsAddComments.Open strSQL, adoCon
'Tell the recordset we are adding a new record to it
rsAddComments.AddNew
'Add a new record to the recordset
rsAddComments.Fields("Name") = Request.Form("name")
rsAddComments.Fields("Comments") = Request.Form("comments")
'Write the updated recordset to the database
rsAddComments.Update
'Reset server objects
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing
'Redirect to whatever page you want
Response.Redirect "newpage.asp"
%>

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQLserver 2000 vs SQLserver 2005 Express cJeffreywang BOOK: Beginning ASP.NET 2.0 and Databases 0 April 22nd, 2007 09:52 AM
Inserting picture into Sqlserver using JSp Thushara Jacob Pulickal Pro JSP 0 May 4th, 2006 12:42 AM
Displaying SQLServer data to user sss22 ASP.NET 1.0 and 1.1 Basics 1 October 28th, 2005 01:05 PM
How to write xml data in SqlServer rekha_jsr XML 1 October 21st, 2004 12:22 PM
casting textbox to sqlserver number data type yoord BOOK: Beginning ASP.NET 1.0 1 October 17th, 2004 06:09 AM



All times are GMT -4. The time now is 08:22 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.