If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Regarding the Adding of a records

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-16-04, 00:47
praveenppandey praveenppandey is offline
Registered User
 
Join Date: Aug 2004
Posts: 28
Regarding the Adding of a records

Hello Members

I want to know how to add the records into MSSQL 2000 through ASP pages.

I also need to know how to show the same records I have added.

N.B. : IF the code snippet can be provided then it is highly appriciated.

Regards
Praveen Kumar Pandey


CoVisible Solutions, The Ultimate Outsourcing Channel
Reply With Quote
  #2 (permalink)  
Old 09-17-04, 13:39
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
There are a ton of tutorials online for exactly this.. but the basic idea is this:

<ServerAddress> = IP or DNS address to SQL server
<Database> = DB name on the SQL server to connect to
<DBUser> = Username that has access to the DB
<DBPassword> = Password for username

"myTable" = The table you want to quey
"Column1" = The name of the column you want to return

Code:
<!-- #include virtual="inc-adovbs.asp" -->
<%
Dim strDBConn, sSQL 
Dim objDataCmd, objconn, objrs 

sDBConn="Provider=SQLOLEDB; Data Source=<ServerAddress>; Initial Catalog=<Database>; User Id=<DBUser>; Password=<DBPassword>; Network Library=DBMSSOCN"

set objDataCmd = server.CreateObject("ADODB.Command")
set objconn = server.CreateObject ("ADODB.connection")
set objrs = server.createObject("ADODB.recordset")

objconn.Open sDBConn
objDataCmd.ActiveConnection = objconn

sSQL = "SELECT * FROM myTable"
objDataCmd.CommandText = sSQL
set objrs = objDataCmd.Execute ( , ,adCmdText)

If NOT objrs.BOF AND NO objrs.EOF Then
  While NOT objrs.EOF
    Response.Write objrs("Column1") & "<BR>"

    objrs.MoveNext
  WEnd
End If

objconn.Close
			
set objrs = Nothing
set objconn = Nothing
set objDataCmd = Nothing
%>
You'll need the attached include file.
__________________
That which does not kill me postpones the inevitable.
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On