Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 8th, 2008, 09:03 AM
nathj's Avatar
Expert
 
Join Date: May 2007
Location: North Tyneside
Posts: 774
Default ASP and MySql - Connection Error

Hi,

I'm new to ASP, I normally develop in PHP but this little project requires me to use ASP. Being a newbie in this I've run into some difficulty.

I'm modifying code from a third party. Basicaly there is a site which I am replacing next year with a new branded version and this new site is powered bya DB. However, the existing site needs to be kept up to date as well. So rather than hard code HTMl for the event listing on the existing site as well as update the DB on the new site I thought I would use the DB to generate the event listing on the existing site.

Right, thats the background, here's the problem.

Quote:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1044: Cannot use more than one type in a for, using, fixed, or declaration statement
So the code looks like:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page language="c#" Codebehind="events.aspx.cs" AutoEventWireup="false" Inherits="ChristianLeadersForum.events" %>
  2. <%@Register TagPrefix="Controls" TagName="Navigation" Src="Controls/Navigation.ascx" %>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  4.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  6. <head>
  7.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  8.     <title>Christian Leaders' Forum - Information</title>
  9.     <link rel="stylesheet" type="text/css" href="_common/css/screen.css" />
  10. <!--[if IE 6]>
  11.     <link rel="stylesheet" type="text/css" href="_common/css/ie6    .css" />
  12. <![endif]-->
  13. </head>
  14. <body>
  15. <div id="masthead">
  16.     <div id="container">
  17.     <h1><img src="_common/img/logo-clf.png" alt="Christian Leaders' Forum" /></h1>
  18.     <Controls:Navigation id="Navigation" Runat="server"></Controls:Navigation>
  19.     </div>
  20. </div>
  21. <div id="wrap">
  22.     <div id="wrap-content" class="cf"> 
  23.     <% 
  24.         Dim sConnection, objConn , objRS 
  25.  
  26.         sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=ip:servername; DATABASE=myDB; UID=user;PASSWORD=password; OPTION=3" 
  27.  
  28.         Set objConn = Server.CreateObject("ADODB.Connection") 
  29.  
  30.         objConn.Open(sConnection) 
  31.  
  32.         Set objRS = objConn.Execute("SELECT a.ID, a.venueID, a.speakerID, a.thumbnail, a.title, a.summary, a.details, a.isFood, a.canBook, concat(date_format(a.startDate,'%D-'), date_format(a.endDate, '%D %b %Y')) as date1, date_format(a.startDate, '%D %b %Y') as date2, a.startDate, a.endDate, a.startTime, a.endTime, b.URL, b.name, b.line1, b.line2, b.postcode, c.name as speaker, c.biog, c.image FROM tbl_event a LEFT OUTER JOIN tbl_venue b on b.ID = a.venueID LEFT OUTER JOIN tbl_speaker c on c.ID = a.speakerID")
  33.  
  34.         While Not objRS.EOF
  35.         Response.Write & "<h3>" & objRS.Fields("title") & "</h3>"
  36.         Response.Write & "<p></p><h3>Date: </h3>"     
  37.         If objRS.Fields("endDate") > objRS.Fields("startDate") Then
  38.             Response.Write & objRS.Fields("date1")
  39.         Else
  40.             Response.Write & objRS.Fields("date2")
  41.         End If
  42.         Response.Write & "<h3>Venue: </h3>"      
  43.         Response.Write & "<p><a target='_blank' title='google map of venue' href='" & onjRS.Fields["URL"] & "'>" & objRS.Fields["name"] & "</a><br />"
  44.         Response.Write & objRS.Fields["line1"] & "<br />" & objRS.Fields["line2"] & "<br />" & objRS.Fields["postcode"] & "</p>" & 
  45.         Response.Write & "<h3>Extra Information: </h3>" & onjRS.Fields["details"]
  46.         objRS.MoveNext
  47.         Wend 
  48.  
  49.         objRS.Close
  50.         Set objRS = Nothing
  51.         objConn.Close
  52.         Set objConn = Nothing  
  53.     %>
  54.     </div>
  55.     <p id="footer">&copy; Christian Leaders' Forum 2007. <a href="http://www.mandogroup.com/">Web Design by Mando Group.</a></p>
  56. </div>
  57. </body>
  58. </html>
  59.  
If someone can point me in the right direction and help me out with this that would be great.

Many thanks
nathj
Reply
  #2  
Old September 8th, 2008, 10:12 AM
codegecko's Avatar
Moderator
 
Join Date: May 2007
Location: United Kingdom
Age: 21
Posts: 341
Default

Hi nathj,

Firstly, are you using classic ASP or ASP.NET? There is a distinct difference between the two.
Your inline code suggests you are using classic ASP but the declarations before the <!DOCTYPE> tag are for ASP.NET only, hence why there is immediate confusion.

Let us know what language you are writing in (classic ASP or ASP.NET) and we can guide you further. If you can't tell us that, then we can translate the code into one or the other for you in very little time.

Best regards,

medicineworker
Reply
  #3  
Old September 8th, 2008, 10:16 AM
nathj's Avatar
Expert
 
Join Date: May 2007
Location: North Tyneside
Posts: 774
Default

Quote:
Originally Posted by medicineworker
Hi nathj,

Firstly, are you using classic ASP or ASP.NET? There is a distinct difference between the two.
Your inline code suggests you are using classic ASP but the declarations before the <!DOCTYPE> tag are for ASP.NET only, hence why there is immediate confusion.

Let us know what language you are writing in (classic ASP or ASP.NET) and we can guide you further. If you can't tell us that, then we can translate the code into one or the other for you in very little time.

Best regards,

medicineworker
Hi medicineworker,

I must be honest I have no idea. I didn't write this site myself, I am just maintaining it for 6 months. I thought it was classic asp but if the <DOCTYPE> indicates othrewsie then perhaps it's asp.Net.

I don't have .Net installed (I have the discs though). I guess I'll have to bow to your superior knowledge as on this one I don't have a clue.

Cheers
nathj
Reply
  #4  
Old September 8th, 2008, 10:31 AM
codegecko's Avatar
Moderator
 
Join Date: May 2007
Location: United Kingdom
Age: 21
Posts: 341
Default

Hi nathj,

This is what causes confusion:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page language="c#" Codebehind="events.aspx.cs" AutoEventWireup="false" Inherits="ChristianLeadersForum.events" %>
  2. <%@Register TagPrefix="Controls" TagName="Navigation" Src="Controls/Navigation.ascx" %>
  3.  
That is ASP.NET declaration code - it tells the web server that the page being processed is an ASP.NET page and therefore the ASP.NET engine should handle the processing of it.

However the code between <% and %> in the document body is classic ASP.

Do you need the in-built navigation control that the page is trying to include (<Controls:Navigtation runat="server"></Controls:Navigtation>)?

Best regards,

medicineworker
Reply
  #5  
Old September 8th, 2008, 10:34 AM
nathj's Avatar
Expert
 
Join Date: May 2007
Location: North Tyneside
Posts: 774
Default

Quote:
Originally Posted by medicineworker
Hi nathj,

This is what causes confusion:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page language="c#" Codebehind="events.aspx.cs" AutoEventWireup="false" Inherits="ChristianLeadersForum.events" %>
  2. <%@Register TagPrefix="Controls" TagName="Navigation" Src="Controls/Navigation.ascx" %>
  3.  
That is ASP.NET declaration code - it tells the web server that the page being processed is an ASP.NET page and therefore the ASP.NET engine should handle the processing of it.

However the code between <% and %> in the document body is classic ASP.

Do you need the in-built navigation control that the page is trying to include (<Controls:Navigtation runat="server"></Controls:Navigtation>)?

Best regards,

medicineworker
Hi medicineworker,

Thanks fro the swift reply.

I do need that code - as this is the main navigation of the page. The alternative I guess is to simply duplicate that navigation code, unless you can convert the code I have written (classic ASP) into ASP.net?

Many thanks
nathj
Reply
  #6  
Old September 8th, 2008, 10:54 AM
codegecko's Avatar
Moderator
 
Join Date: May 2007
Location: United Kingdom
Age: 21
Posts: 341
Default

Hi nathj,

Converting ASP.NET to ASP (the main navigation) will be more time-consuming that converting the classic ASP code to .NET.

I will review your code on my lunch break and see what I can come up with.

Best regards,

medicineworker

P.S. ASP.NET runtimes (the binaries needed to compile and interpret .NET code) come as redistributables from Microsoft's website (and pre-packaged with Windows XP SP3 onwards), and the classic ASP runtimes are already included on all Windows OS's since NT4. If you would consider getting into .NET (you mentioned you're a predominantly PHP programmer) then I recommend going to Microsoft's website and downloading Visual Web Developer Express Edition and Microsoft SQL Server Express Edition - both are free to download and use for personal usage (or MySQL Community Edition and the .NET connector), it'll give you a good start to kick off ASP.NET web development. I also recommend a number of good reference books by O'Reilly or Sams Publishing.
Reply
  #7  
Old September 8th, 2008, 10:57 AM
nathj's Avatar
Expert
 
Join Date: May 2007
Location: North Tyneside
Posts: 774
Default

Quote:
Originally Posted by medicineworker
Hi nathj,

Converting ASP.NET to ASP (the main navigation) will be more time-consuming that converting the classic ASP code to .NET.

I will review your code on my lunch break and see what I can come up with.

Best regards,

medicineworker

P.S. ASP.NET runtimes (the binaries needed to compile and interpret .NET code) come as redistributables from Microsoft's website (and pre-packaged with Windows XP SP3 onwards), and the classic ASP runtimes are already included on all Windows OS's since NT4. If you would consider getting into .NET (you mentioned you're a predominantly PHP programmer) then I recommend going to Microsoft's website and downloading Visual Web Developer Express Edition and Microsoft SQL Server Express Edition - both are free to download and use for personal usage (or MySQL Community Edition and the .NET connector), it'll give you a good start to kick off ASP.NET web development. I also recommend a number of good reference books by O'Reilly or Sams Publishing.
Hi medicineworker,

Thanks for the help and for the advice. I really appreciate you taking the time to help me out.

Many thanks
nathj
Reply
  #8  
Old September 8th, 2008, 11:41 AM
nathj's Avatar
Expert
 
Join Date: May 2007
Location: North Tyneside
Posts: 774
Default

I got to thinking about the ASP.Net and classic ASP issue and decided I would remove the .net stuff, duplicate the navigation and see what happens.

On doing this I get a bit further but it's not quite right. If you take a look at www.christianleadersforum.com.events.asp you'll see what I mean.

Can you shed any light on this?

Many thanks
nathj
Reply
Reply

Bookmarks

Thread Tools

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 Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles