473,704 Members | 3,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP and SQL help - I don't know what I'm doing

14 New Member
I don't know a lot about ASP and I know even less about SQL. I have been trying to search the web for information to be able to get done what I need. I've tried piecing things together from many different sites, adding my own info in where needed, but it just isn't working.

What I want to do is, using an existing database setup for a calendar application, pull information out of the database and display a title of an entry that corresponds with the current date.

http://www.godfreyfritzs.com

if you go to the address above, you will see that there is a sign graphic which has text over it that says an ice cream flavor. Right now I am using AJAX scripting to display a different HTML file for each day of the month, because the Flavor of the day changes every day. I want to pull the flavor of the day from the calendar, since the manager will have the flavors of the day in the calendar as events.

here's what i've got in a test file.

Expand|Select|Wrap|Line Numbers
  1. <%
  2.  
  3. Set conn = Server.CreateObject("ADODB.Connection")
  4. conn.Open "Driver={SQL Server};Server=SERVERLOCATION;Database=DATABASENAME;Uid=MYUSERNAME;Pwd='MYPASSWORD';"
  5.  
  6. SQL ="SELECT event_title FROM events"
  7.  
  8.     Dim objRec
  9. Set objRec = Server.CreateObject("ADODB.Recordset")
  10. objRec.Open SQL, objConn, 0, 1, 2
  11.  
  12. %>
  13.  
I had this setup to test if I could even pull data from the database, to no avail:

Expand|Select|Wrap|Line Numbers
  1. Microsoft OLE DB Provider for ODBC Drivers error '80040e4d'
  2.  
  3. [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'USERNAME'.
  4.  
  5. /testing.asp, line 4
Apparently I've done something wrong, but I have no idea what. I don't understand what I am trying to do. I have read many things on the internet about ASP and SQL but they are no help. The lady I made that website for really likes how the flavor of the day shows up there, but for her to change the 31 files that correspond with the days of the month individually would be a mess for her to deal with. It would be a lot easier to insert an event into a day with the category of "Flavor of the Day" and then pull that day's Flavor out of the database, cause she would have one thing to do instead of lots and lots of things to do.

Any help would be appreciated.
Mar 17 '07 #1
20 3764
johnnyboy7
14 New Member
OK, fixed a problem....had my password in these things ' ' ......

but now i get this message in the browser:

ADODB.Recordset error '800a0bb9'

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

/testing.asp, line 10



here's my code again:

Expand|Select|Wrap|Line Numbers
  1. <%
  2.  
  3. Set conn = Server.CreateObject("ADODB.Connection")
  4. conn.Open "Driver={SQL Server};Server=SERVERNAME;Database=DATABASENAME;Uid=USERNAME;Pwd=PASSWORD;"
  5.  
  6. SQL ="SELECT event_title FROM events"
  7.  
  8.     Dim objRec
  9. Set objRec = Server.CreateObject("ADODB.Recordset")
  10. objRec.Open SQL, objConn, 0, 1, 2
  11.  
  12. %>


so, to try and fix it I tried this (which I found on some website telling about asp and sql):

Expand|Select|Wrap|Line Numbers
  1. <%
  2.  
  3. Set conn = Server.CreateObject("ADODB.Connection")
  4. conn.Open "Driver={SQL Server};Server=SERVERNAME;Database=DATABASENAME;Uid=USERNAME;Pwd=PASSWORD;"
  5.  
  6. SQL ="SELECT event_title FROM events"
  7.  
  8.     Dim objRec
  9. Set objRec = objConn.Execute(SQL)
  10. %>
But then I get this:

Microsoft VBScript runtime error '800a01a8'

Object required: 'objConn'

/testing.asp, line 9
Mar 17 '07 #2
jhardman
3,406 Recognized Expert Specialist
Expand|Select|Wrap|Line Numbers
  1. <%
  2.  
  3. Set conn = Server.CreateObject("ADODB.Connection")
  4. conn.Open "Driver={SQL Server};Server=SERVERNAME;Database=DATABASENAME;Uid=USERNAME;Pwd=PASSWORD;"
  5.  
  6. SQL ="SELECT event_title FROM events"
  7.  
  8.     Dim objRec
  9. Set objRec = objConn.Execute(SQL)
  10. %>
But then I get this:

Microsoft VBScript runtime error '800a01a8'

Object required: 'objConn'

/testing.asp, line 9
Some people like to use the word "objConn" as a default name for a db connection, and others like to call it "conn". It doesn't really matter, you could call it "george" if you wanted, you just have to use the same name throughout. When you declared the connection object, you called it "conn" so you need to change every reference to say "conn" instead of "objConn", or declare it as "objConn" to start.

Jared
Mar 20 '07 #3
johnnyboy7
14 New Member
Thanks for helping out.

except now i get this error

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'SELECT'.

/testing.asp, line 11

on this code

Expand|Select|Wrap|Line Numbers
  1. Dim conn
  2. Set conn = Server.CreateObject("ADODB.Connection")
  3. conn.Open "Driver={SQL Server};Server=p3swhsql-v03.shr.phx3.secureserver.net;Database=DB_1003645;Uid=****;Pwd=****;"
  4.  
  5. SQL ="SELECT event_title FROM events WHERE"
  6.  
  7. Dim objRec
  8. Set objRec = Server.CreateObject ("ADODB.Recordset")
  9. objRec.Open SQL, conn, 0, 1, 2
  10.  
  11. Response.Write objRec
  12.  
Edited by iam_clint reason: Removed username and password from code.
Mar 25 '07 #4
johnnyboy7
14 New Member
sorry, i changed back to this:

Expand|Select|Wrap|Line Numbers
  1. Dim conn
  2. Set conn = Server.CreateObject("ADODB.Connection")
  3. conn.Open "Driver={SQL Server};Server=p3swhsql-v03.shr.phx3.secureserver.net;Database=DB_1003645;Uid=****l;Pwd=****;"
  4.  
  5. SQL = "SELECT event_title FROM events"
  6.  
  7. Dim objRec
  8. Set objRec = conn.Execute(SQL)
  9.  
  10. Response.Write objRec

and then I get this error:

Response object error 'ASP 0185 : 8002000e'

Missing Default Property

/testing.asp, line 0

A default property was not found for the object.

And I even tried changing this line

Expand|Select|Wrap|Line Numbers
  1. Response.Write objRec
to this

Expand|Select|Wrap|Line Numbers
  1. Response.Write SQL
but all that did was give me this outcome in plain text:

SELECT event_title FROM events

I don't understand what I'm going wrong. How come I can't pull this info from the table and display it on the page?

Edited by iam_clint reason: Removed username and password from code.
Mar 25 '07 #5
johnnyboy7
14 New Member
YAY something worked!

Ok, after studying a couple of other ASP pages that accessed data from a SQL database as well as reading this sites forums on default datasets or something like that, I edited my code to the below:

Expand|Select|Wrap|Line Numbers
  1. Dim conn
  2. Set conn = Server.CreateObject("ADODB.Connection")
  3. conn.Open "Driver={SQL Server};Server=p3swhsql-v03.shr.phx3.secureserver.net;Database=DB_1003645;Uid=****;Pwd=****;"
  4.  
  5. SQL = "SELECT event_title FROM events WHERE category_id='4'"
  6.  
  7. Dim objRec
  8. Set objRec = Server.CreateObject("ADODB.Recordset")
  9. objRec.Open SQL,conn,0,1
  10.  
  11. Response.Write objRec.Fields.Item(0).Value
  12.  
  13. objRec.close
  14.  
  15. conn.close
  16. set conn=nothing

I got a result from my database! A correct result, too. Now what I want to do is display the item from that table that matches today's date. How do I query that? Is it still in the WHERE part or is it something else?

thanks for any help!
Mar 25 '07 #6
jhardman
3,406 Recognized Expert Specialist
I got a result from my database! A correct result, too. Now what I want to do is display the item from that table that matches today's date. How do I query that? Is it still in the WHERE part or is it something else?
yes, the "WHERE" clause tells which records you want to access. you can add new parts to the WHERE clause very easily:
Expand|Select|Wrap|Line Numbers
  1. SQL = "SELECT event_title FROM events WHERE category_id='4'"
  2. SQL = SQL & " AND entryDate = " & date()
By the way, the SELECT statement tells which fields in the record you want to access (if you want to see them all, say "SELECT *") and the FROM clause tells which table or tables you want to look in (to look in more than one, say "FROM events, locations").
Let me know if this helps.

Jared
Mar 26 '07 #7
johnnyboy7
14 New Member
here's the code

Expand|Select|Wrap|Line Numbers
  1. Dim conn
  2. Set conn = Server.CreateObject("ADODB.Connection")
  3. conn.Open "Driver={SQL Server};Server=p3swhsql-v03.shr.phx3.secureserver.net;Database=DB_1003645;Uid=***;Pwd=***;"
  4.  
  5. SQL = "SELECT event_title FROM events WHERE category_id = '4'"
  6. SQL = SQL & " AND event_date = " & date()
  7.  
  8. Dim objRec
  9. Set objRec = Server.CreateObject("ADODB.Recordset")
  10. objRec.Open SQL,conn
  11.  
  12. Response.Write objRec.Fields.Item(0).Value
  13.  
  14. objRec.close
  15.  
  16. conn.close
  17. set conn=nothing

here's the error

ADODB.Field error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/testing.asp, line 14

Is my query setup wrong? I know I have an entry in that table and column for the date and all... Should I use some type of code to make sure that my dates are in the same format? I'm not exactly sure how the calendar I use puts the date into the database.

Thanks for your help! :)


Edited by iam_clint reason: Removed username and password from code.
Mar 26 '07 #8
johnnyboy7
14 New Member
OK, I found another article I think on this site about using dates and that person told the other guy to use the actual date of that day (or a date he wanted) and plug that into the WHERE to see if it even worked that way. I did this and it worked:

Expand|Select|Wrap|Line Numbers
  1. SQL = "SELECT event_title FROM events WHERE category_id = '4'"
  2. SQL = SQL & " AND event_date = '3/26/2007'"
So I know that I am on the right track with this. However, something isn't working when I try to use the current date (which would change each day). in the database, which is a SQL database, the 'type' for the date column is "datetime" if that helps any.

Thanks so much!
Mar 26 '07 #9
iam_clint
1,208 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. SQL = SQL & " AND event_date = '" & date() & "'"
this will work.

never post usernames or passwords anywhere.
Mar 26 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

303
17661
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b. Yahoo store was originally written in Lisp. c. Emacs The issues with these will probably come up, so I might as well mention them myself (which will also make this a more balanced
16
2192
by: Jace Benson | last post by:
Ok I have read alot of things on zend.com, php.net and other sites went to the wikibooks to try to understand how to use a class. I have this project I want to do that I am sure would work great with a class. I just don't grasp the whole concept, and how to do it. I want to make a Collectable Card Game Draft Engine...(if any of you play VS System, LOTR, Magic: The Gathering, you know what I am talking about.) It would be way to...
0
17795
by: Nashat Wanly | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaskdr/html/askgui06032003.asp Don't Lock Type Objects! Why Lock(typeof(ClassName)) or SyncLock GetType(ClassName) Is Bad Rico Mariani, performance architect for the Microsoft® .NET runtime and longtime Microsoft developer, mentioned to Dr. GUI in an e-mail conversation recently that a fairly common practice (and one that's, unfortunately, described in some of our...
2
1413
by: John | last post by:
Hi all, I really don't know where to post this question but it is urgent and I need resolution on this. I just re-installed my Windows since it was just downloading something from the internet. I tracked it to an svchost process but don't know anything further and I need to find out what app is doing this. The reason for this is that I'm in South Africa and we get capped with our bandwidth here to 3 Gig/month. After that, the internet...
0
2062
by: orientphoebus | last post by:
I tried the new Visual Studio 2005 Team System + VSS2005, no Team Foundation Server. Some questions pop into my head: 1. WITHOUT TFS, can VSS2005 integrated with VS2005? What I like is the VS6 kind of integration: when I modify a source file in VisualStudio, VS found out it's readonly and controled by VSS, then pop up a dialog for me to check out from VSS. It seems like even with TFS, the integration between VSS and VS is not the same....
5
1396
by: UJ | last post by:
I have a try catch where I don't know all of the exceptions that can be thrown (I'm calling a web service in the try) and what I would ideally like to do is a catch all but then look at the type of exception that was thrown and decide what to do there. Because I don't know what all can be thrown I need to have sort of a generic exception where I can then say - what type is it ? and then process accordingly. I don't want to do a (Execption...
2
1853
by: ThunderMusic | last post by:
hi, I have 2 services running, one doing a job and the other monitoring the job is done and that the other service (the one doing the job) is still running. The thing is, the 1st service fire some events notifying other programs that an alert happened... I want to register to that event in my second service, but I just can't get it working... I receive the following message : Type System.DelegateSerializationHolder and the types...
0
3007
by: U S Contractors Offering Service A Non-profit | last post by:
" Visionary Dreams " " Leaving New york City leaving to go " GOD noes were i Don't "
10
2096
by: Frank | last post by:
I've done this a few times. In a solution I have a project, Say P1, and need another project that will contain much code that is similar to that of P1. I hope no one gets hung up on why I don't somehow share the code. So, I copy the folder P1 is in, change the new folder name, and is VS2005 to change all occurrences of P1's name tp P2's name.
21
2058
by: jehugaleahsa | last post by:
Hello: I had an hour-long discussion with my boss today. Last night, right before I dozed off, I realized some of his code resulted in duplicate processing. I tried to explain it to him and he kept saying, "I'm afraid to say it's 'OK' to change it because everything I did was for a reason." Well, I know better. My boss' old code is written in some cryptic C file with Oracle precompiler macros barfed all over it. Once I figured out how...
0
8677
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9266
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9130
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5926
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4435
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4694
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3130
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2468
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2074
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.