Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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
  #11 (permalink)  
Old June 2nd, 2004, 01:56 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

lol, Okay I just remembered something, do I have to link these two tables in say EM, do I have to assign a primary kay, secondary key and all that stuff. Because I can't get anything to work

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

This is all I get. When a record is inserted into Table2, EventId is updated in both tables. So I thought that is all I would need, but I get the error on this line
objAuthorsAndBooks.ActiveConnection = MyConnectionString

-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
Reply With Quote
  #12 (permalink)  
Old June 2nd, 2004, 02:08 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Design-wise it's a very good idea to enforce these relation ships in the database, for this example it's not required. If you add the relations in the database, you can be sure you'll never add an item in table 2 that doesn't have a match in table 1.

How does your table structure look like? And your current SQL statement? If you run the SQL in the database (query analyzer) directly, do you get any results?

Can you post relevant parts of your code?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #13 (permalink)  
Old June 2nd, 2004, 02:18 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Also, did you change MyConnectionString to a suitable connection string??

Imar
Reply With Quote
  #14 (permalink)  
Old June 2nd, 2004, 02:30 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Minneapolis, MN, USA.
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

"out of exceptable range"? Did you try replacing "cn" with whatever variable your connection string is set to?

MsSql Example:
set cn = server.createobject("adodb.connection")
cn.connectionString = "provider=sqloledb.1; user id=YourUserName; password=YourPassword; data source=MachineName; initial catalog=DatabaseName"
cn.mode=1
cn.cursorlocation=3
cn.open

MsAccess Example:
set cn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\YourDatabase.mdb;User Id=YourUserName;Password=YourPassword;"

Reply With Quote
  #15 (permalink)  
Old June 2nd, 2004, 02:32 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay here is my code with the SQL statment I was using. What do you mean by a suitable connection string? I just changed the name to somehting realated to the tables.
But it wont go past this line
  "objEvents.ActiveConnection = CSRaceResults"

<%
    SQLStr="SELECT * FROM ABNRaceResults inner join ABNYachtClub on ABNRaceResults.EventId = ABNYachtClub.EventId"
    Set RS=Server.CreateObject("ADODB.Recordset")
    RS.Open SQLStr,Application("DBConn"),adOpenKeyset,adLockPe ssimistic,adCmdText

  Dim objEvents
  Dim rsEvents

    Set objEvents = Server.CreateObject("ADODB.Command")
  objEvents.ActiveConnection = CSRaceResults
  objEvents.CommandType = &H0001
  objEvents.CommandText = "SELECT ABNYachtClub.Event, ABNRaceResults.BoatName, " & _
        "ABNRaceResults.SailNum FROM ABNYachtClub INNER JOIN ABNRaceResults on ABNYachtClub.EventId = ABNRaceResults.EventId ORDER BY ABNYachtClub.Event"
  Set rsEvents = objEvents.Execute()
  Set objEvents = Nothing
  With rsEvents
    Dim OldEventName
    If Not .EOF then
      ' Loop through entire recordset with duplicate author data and books
      Do While Not .EOF
        ' Are we displaying the same Event as the previous record?
        ' This will not be the case for the first record
        ' and also not when you "switch" Events.
        If .Fields("Event").Value <> OldEventName Then
          ' No, so display Event name, and update OldEventName variable
          OldEventName = .Fields("Event").Value
          Response.Write("<h2>" & .Fields("Event").Value & "</h2>")
        End If
        ' Now display the Placing stuff
        Response.Write(.Fields("BoatName").Value & "(" & _
               .Fields("SailNum").Value & ")<br />")
        .MoveNext()
      Loop
    End If
    .Close
    Set rsEvents = Nothing
  End With
%>

-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
Reply With Quote
  #16 (permalink)  
Old June 2nd, 2004, 02:38 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

And how do you think your application knows where to look for the data? How do you think it finds your Access database or SQL Server database??

The ActiveConnection property needs an open connection object, or a connection string. Simply assigning a good sounding variable name isn't good enough..... ;)

For connection string examples, look here:

SQL Server
http://www.able-consulting.com/MDAC/...erForSQLServer

Access
http://www.able-consulting.com/MDAC/...orMicrosoftJet
Reply With Quote
  #17 (permalink)  
Old June 2nd, 2004, 02:48 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

CSRaceResults.Open "Provider=sqloledb;" & _
           "Data Source=myServerName;" & _
           "Initial Catalog=myDatabaseName;" & _
           "Integrated Security=SSPI"

Would I use it like this? Then fill in my DB and Server Name. I treid it and I get an

Object required: "

Error on the first line.

-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
Reply With Quote
  #18 (permalink)  
Old June 2nd, 2004, 02:50 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

After reading this again, I see you're mixing up two things: you're using code that opens a Recordset directly, while I use an intermediate Command object to get the data. You can drop the command object and use your own Recordset stuff, like this:
Code:
<%
  Dim rsEvents
  SQLStr="SELECT ABNYachtClub.Event, ABNRaceResults.BoatName, " & _
        "ABNRaceResults.SailNum FROM ABNYachtClub INNER JOIN   
      ABNRaceResults on ABNYachtClub.EventId = ABNRaceResults.EventId 
      ORDER BY ABNYachtClub.Event"
  Set rsEvents=Server.CreateObject("ADODB.Recordset")
  rsEvents.Open SQLStr,Application ("DBConn"),adOpenKeyset,adLockPessimistic,adCmdText

  With rsEvents
    Dim OldEventName
    assuming that I copied the right SQL statement.

Cheers,

Imar
Reply With Quote
  #19 (permalink)  
Old June 2nd, 2004, 02:58 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wow, I think that's right :-). That's why I was getting confused I knew I was already connected to the database. I think it's working now, but I am of for the day so I will check back tomorrow.

Thanks a lot for your help, you are the man!!!

-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
Reply With Quote
  #20 (permalink)  
Old June 2nd, 2004, 04:31 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Minneapolis, MN, USA.
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Imar, who are you referring to?

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
Loop through 17 tables in RecordSet object didimichael C# 1 July 18th, 2008 06:53 AM
loop through tables inside .mdb file using VB.NET remya1000 General .NET 3 September 24th, 2007 12:45 PM
creating tables within tables in access??? carswelljr Access 3 August 23rd, 2006 01:21 PM
Help with for-each loop athanatos XSLT 0 April 10th, 2006 07:20 PM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM



All times are GMT -4. The time now is 06:01 PM.


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