ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 12th, 2002, 06:20 PM
coraxal coraxal is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 4 coraxal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry newbie here

Hello guys...I'm migrating to SQL 2000 and ASP having C/C++ background....I need to develop a project for my work....I need to develop a simple ASP module which will connect to a simple SQL 2000 database.....let's say that this database has only three columns...lastN, middleN, and firstN (really basic database)....what I'm trying to accomplish is the following....1) be able to connect to the database from an ASP page 2) ASP page should allow to manipulate database records (really simple functions such as add, modify, delete records)...like i said I'm kinda new at this....I tried to make the connection but it didnt work...this is what i did....I made my connection in the global.asa as follows

---global.asa----

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Application_OnStart()
Dim strConn
strConn = "Provider=SQLOLEDB.1; Data Source=servername; Initial Catalog=databasename; User Id=username; Password=password"
Application("strConn") = strConn
End Sub
</Script>

---test.asp--this page is not trying to do any functions other than making the connection to the database and displaying records

1 <% Option Explicit %>
2 <html>
3 <head>
4 <title>test asp page</title>
5 </head>
6 <body>
8 <ol>
9 <%
10 Dim objConn
11 Set objConn = Server.CreateObject("ADODB.Recordset")
12 objConn.Open "table's name", Application("strConn")
13
14 Do While Not objConn.EOF
15 Response.Write "<li><b>" & objConn("lastN") & "</b>"
16 Response.Write "<p>" & objConn("firstN") & "</p></li>"
17 objConn.MoveNext
18 Loop
19 If objConn.BOF Then
20 Response.Write "<p>No more records in the database!</p>" & vbNewLine
21 End If
22
23 objConn.Close
24 %></ol>
25 </body>
26 </html>

I know that you guys will look at this and it'll be a simple problem...once again...im only a newbie at this..so any help would be greatly appreciated....maybe someone can point me in the right direction.....Thanks!

P.S. what I'm trying to accomplish here....is to connect a simple database to a page and show the records of that database (only 3 names stored in the database)

Reply With Quote
  #2  
Old November 12th, 2002, 08:50 PM
markerdave markerdave is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Illinois, USA
Posts: 71 markerdave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
coraxal,

Hi! You need to query the database in order to retrieve any data from it. That means you needs to write SQL queries. There are many ways to do this. Try adding:

strSQL = "SELECT * FROM table_name"
Set objRS = objConn.Execute (strSQL)

between lines 12 and 14 and then changing objConn to objRS in lines 14, 17, and 19. You will also want to close the objRS object before the script ends. You might want to check out a tutorial about ADO and/or SQL. Hope this helps.

Reply With Quote
  #3  
Old November 14th, 2002, 03:04 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 7
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
hi coraxal,

to add to markerdave:

Code:
Dim oConn, oRs

Set oConn = Server.CreateObject("ADODB.Connection")
oCnn.Open Application("strConn")

Set oRS = oConn.Execute ("SELECT * FROm tablename")

If oRS.EOF Then
   Response.WRite "no records found<BR>"
Else

 Do While Not oRs.EOF
   Response.Write oRs.Fields("field1") & "<BR>"
 Loop
End If

oRs.Close
Set oRs = Nothing

'important that you close the connection!
oCnn.Close
Set oCnn = Nothing

-Rogier
__________________
- Rogier Doekes

Reply With Quote
  #4  
Old November 14th, 2002, 09:34 PM
coraxal coraxal is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 4 coraxal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks

Thanks very much guys.....I'll try that...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > newbie here


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT