 |
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 2nd, 2004, 01:56 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 2nd, 2004, 02:08 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|

June 2nd, 2004, 02:18 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Also, did you change MyConnectionString to a suitable connection string??
Imar
|
|

June 2nd, 2004, 02:30 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
|
|
"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;"
|
|

June 2nd, 2004, 02:32 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 2nd, 2004, 02:38 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 2nd, 2004, 02:48 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 2nd, 2004, 02:50 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 2nd, 2004, 02:58 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 2nd, 2004, 04:31 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Imar, who are you referring to?
|
|
 |