Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

asp writing code to a file

  • 26-06-2006 5:58pm
    #1
    Registered Users, Registered Users 2 Posts: 68 ✭✭


    Hi
    I'm having a problem creating an asp page based on the users input.
    Im getting this error message when I click the submit button.

    Error Type:
    Microsoft VBScript compilation (0x800A03EE)
    Expected ')'
    /test/appdetails.asp, line 38, column 49
    RqFile.Writeline(" Set rs = Server.CreateObject("ADODB.RecordSet") ")


    I think the error as as a result of how i'm handling the brackets can anyone help??:confused:

    <%
    dim User,Status,Email,Darwin,Internet,fs,RqFile,RqType,RqDetails,y,m,d,h,min,sec,fname

    y= Year(NOW())
    m= Month(NOW())
    d= Day(NOW())
    h= Hour(NOW())
    min= Minute(NOW())
    sec= Second(Now())

    set fs=Server.CreateObject("Scripting.FileSystemObject")
    User=Request.QueryString("Name")
    Status=Request.QueryString("Status")
    Email=Request.QueryString("App1")
    Darwin=Request.QueryString("App2")
    Internet=Request.QueryString("App3")

    fname= "tmp" & sec & ".asp"

    set RqFile=fs.CreateTextFile("C:\Dell\tmp.asp")


    RqFile.Writeline("<B>Application Details</B>")
    RqFile.Writeline("<%")
    RqFile.Writeline(" Set rs = Server.CreateObject("ADODB.RecordSet") ")
    RqFile.Writeline("Set recset = Server.CreateObject("ADODB.RecordSet")")
    RqFile.Writeline("q = "SELECT APPROLES.DarwinRoles FROM APPROLES"")
    RqFile.Writeline("p = "SELECT APPROLES.InternetRoles FROM APPROLES"")
    RqFile.Writeline("rs.Open q, "DSN=help;"")
    RqFile.Writeline("recset.Open p, "DSN=help;"")
    RqFile.Writeline("%>")
    %>


Comments

  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    I dont know ASP but I'm going to take a guess and say you cant use quotes within quotes so you have to change

    RqFile.Writeline(" Set rs = Server.CreateObject("ADODB.RecordSet") ")
    RqFile.Writeline("Set recset = Server.CreateObject("ADODB.RecordSet")")

    to

    RqFile.Writeline("Set rs = Server.CreateObject('ADODB.RecordSet')")
    RqFile.Writeline("Set recset = Server.CreateObject('ADODB.RecordSet')")

    But i could be incredibly wrong! :D


  • Registered Users, Registered Users 2 Posts: 4,100 ✭✭✭muckwarrior


    Yeah, I'd be extremely suprised if you didn't have to escape the quotes.


  • Registered Users, Registered Users 2 Posts: 68 ✭✭alancool


    Tanx guys i reckon you could be onto something but i'm new to the area of development [defo not a student seeking shortcuts though] does anyone know of a good resoucre for asp/vbscript (with emphasis on writing to textfiles)??? There are way too many websites to filter and none of them, to my eyes at least, seem to offer help where im stuck.

    Essentially I want my code to interpret the users selections and based on this create another asp page [The name of this page will follow the convention tmp(second at which it will be created).asp EG tmp13.asp and this will be stored in a variable to be passed to a redirect command].

    Using asp to write brackets, sql statements and vbscript to a text file is proving tricky. I need help and I'm prepared to put in the hours (i've already spent many customising my search :( )

    Alan:cool:


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    This seems fairly explanatory:

    http://www.4guysfromrolla.com/webtech/faq/FileSystemObject/faq3.shtml

    Also, when you're trying to write something like
    RqFile.Writeline("rs.Open q, "DSN=help;"")
    

    to a file I imagine that due to the quotes, it will simply write that text rather than process the request. I would guess that for processes, you exclude the quotes.

    But as I said, I've never written asp before! :embarrassment:


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    This seems fairly explanatory:

    http://www.4guysfromrolla.com/webtec...ect/faq3.shtml

    Also, when you're trying to write something like


    Code:
    RqFile.Writeline("rs.Open q, "DSN=help;"")
    to a file I imagine that due to the quotes, it will simply write that text rather than process the request. I would guess that for processes, you exclude the quotes.

    your right it will only write the text not process the request.

    alancool what are you trying/want to do (in english please no code)


  • Advertisement
  • Closed Accounts Posts: 80 ✭✭Torak


    A little off topic but be mindful of the following code
    dim User,Status,Email,Darwin,Internet,fs,RqFile,RqType,RqDetails,y,m,d,h,min,sec,fname
    
    y= Year(NOW())
    m= Month(NOW())
    d= Day(NOW())
    h= Hour(NOW())
    min= Minute(NOW())
    sec= Second(Now())
    

    The problem being that the Now will be different every time.. most of the time this will be ok but at each rollover point there is a potential for problems.

    Something like below might prevent some painful debugging at a later stage..
    dim User,Status,Email,Darwin,Internet,fs,RqFile,RqType,RqDetails,y,m,d,h,min,sec,fname, time
    
    time = Now()
    
    y= Year(time)
    m= Month(time)
    d= Day(time)
    h= Hour(time)
    min= Minute(time)
    sec= Second(time)
    

    On topic, have you considered other ways of making your site dynamic. I think that the approach you are using is commendable and shows a real urge to think outside the box and make things re-usable. I think perhaps though that there are easier and stabler ways of doing what you want.

    It seems that you are trying to create a page that is a snapshot of the system configuration of the system in question. I could be way off track.

    If this is the case a template (fill in the blanks) approach will suit your needs better than a generate page approach.

    Ignore if i am completely and utterly wrong about what you are trying to achieve.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    To escape quotes just put them in twice.

    RqFile.Writeline(" Set rs = Server.CreateObject("ADODB.RecordSet") ")

    becomes

    RqFile.Writeline(" Set rs = Server.CreateObject(""ADODB.RecordSet"") ")

    it can be a little confusing to look at unless you've an editor with syntax higlighting that recognise this, but once you get the hang of it, it works well enough.


  • Registered Users, Registered Users 2 Posts: 68 ✭✭alancool


    Fade to grey, thanks again for taking the time to reply to my post. I continue to be frustrated and somewhat surprised that this problem is proving so difficult to get around.

    I had read the article you referenced at some stage in the past 12 days (the evenings are beginning to blend into each other:o )

    I think this warrants an article or blog when I do eventually arrive at the solution. Although surely someone out there has done this before ..... when using the filesystemobject to write to text files how do you handle double and single quotes???:confused:


    If someone can help please do, if not watch this space and you'll eventually see a clear concise solution born out of exhaustive searching and determination!!;)


    alan:cool:


  • Registered Users, Registered Users 2 Posts: 68 ✭✭alancool


    sorry folks i did not see your posts before replying to fade to grey :o

    thanks for your input stevenmu i'll give it a try.... but that simple??? :o

    torak thanks for the cautionary note its the first time i used the now function. And you are on the ball with the template approach can you elaborate on how I could implement this?

    amen
    ..... when using the filesystemobject to write to text files how do you handle double and single quotes???

    essentially this is want I need help with.

    Thanks folks your input and time is very much appreciated!

    alan:cool:


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    amen
    Quote:
    ..... when using the filesystemobject to write to text files how do you handle double and single quotes???



    essentially this is want I need help with.

    I know thats what you want and the double quote solution everyone has mentioned should work but I was interested in why you are trying to do this?
    Are you trying to log some data or log events to debug somecode?
    Sometimes there is more than one way to skin a cat and if you can tell use more about what you are trying to do there maybe alternative solutions


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 68 ✭✭alancool


    Amen

    I think you might be reading too much into some of the captions in my posted code. My aim for now is to create a dynamic web page in the way described throughout this thread.
    That is create a web page uniquely based on the users selections/input. Perhaps a template would be a better way to go as Torak suggested but my fear is how such a template might grow in complexity and the impact that would have on the end user.

    ......... i dont know much about skinning cats but i dont intend to log events in this way.

    I'd very much welcome any suggestions you might have.

    alan:cool:


  • Closed Accounts Posts: 80 ✭✭Torak


    When I say template what I mean is that you need to ask yourself what actually changes from one page to the next.

    The fact that it is generatable means that there is not much different (but maybe it is different enough that a template will not work).

    An standard "asp" page is essentially a template. There are sections of html. These are the static parts that stay the same across all views of the page. Perhaps the title and logo fall into this category.

    Then there are the dynamic sections. The bits that change from one page view to the next. This could be the current time i.e. the time the page was generated. It could also be the "Internet Roles" associated with the user being viewed (Stolen from your code "p = "SELECT APPROLES.InternetRoles FROM APPROLES"").

    So the question is why is the page required to be generated? What sets it apart from a standard asp template page? Why does it have to be generated on the fly?

    I find it difficult to envisage a scenario where the standard template process does not work..

    If you are not comfortable putting "private code" or requirements on the web and you want me to look at it then feel free to send PM.

    Otherwise I hope I have given you enough information to move forward yourself!!


  • Registered Users, Registered Users 2 Posts: 68 ✭✭alancool


    Torak thank for the reply

    I understand what you mean now thanks for that. I did consider the design options carefully before going down this route and I think a page generated on the fly is probably more complicated in terms of putting it all together and ensuring every eventuality is covered but it would be easier for my user base to come to grips with.

    One other requirement inhibiting the use of a template as you described is the requirment surrounding the window size (approx 1/4 to 1/3 of a maximised window). The volume of information needed in a template would mean a very cluttered looking ui.

    I need to spend more time on this tomorrow but when I feel the code is in slightly better shape I will post it. Thanks for offering the PM option I may take you up on that.

    alan:cool:


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    alancool wrote:
    thanks for your input stevenmu i'll give it a try.... but that simple??? :o
    Yep, it should be, but it's not as simple as it looks at first, wait untill you're trying to concatenate strings and need to figure out if you need to put in 2,3 or 4 of them in a row.


    With that out of the way, I agree with what Torak says, altough 'template' is probably a misleading term for it. Really instead of dynamically generating a page to send the user too based on the options they pick, you should really have a dynamic page that takes in the options from the form and only displays the controls as needed. In this page you'd setup whatever data connections you use as normal, read in the options from the form that called the page and then use if statements to determine what controls you render. It'll be much easier to do initially and much easier to maintain and add to later.


  • Registered Users, Registered Users 2 Posts: 68 ✭✭alancool


    a dynamic page that takes in the options from the form and only displays the controls as needed. In this page you'd setup whatever data connections you use as normal, read in the options from the form that called the page and then use if statements to determine what controls you render.

    Can this be done using asp or I thought it was a function of asp.net?

    alan:cool:


  • Registered Users, Registered Users 2 Posts: 68 ✭✭alancool


    stevenmu wrote:
    To escape quotes just put them in twice.

    RqFile.Writeline(" Set rs = Server.CreateObject("ADODB.RecordSet") ")

    becomes

    RqFile.Writeline(" Set rs = Server.CreateObject(""ADODB.RecordSet"") ")

    stevenmu thanks a lot that worked out as you described but I've now encountered a problem with the % character. Is there a similar method for writing this to a text file?

    alan:cool:


  • Registered Users, Registered Users 2 Posts: 68 ✭✭alancool


    I overcame the %> problem with this code tip

    tfile.WriteLine("%" & chr(62))


    from


    http://www.thescripts.com/forum/thread52323.html


    :) alan:cool:


  • Registered Users, Registered Users 2 Posts: 68 ✭✭alancool


    Thank you everyone, Im on the way back to thinking for myself again.

    I think going forward though doing an asp.net course/cbt would make sense. If anyone has gone down this route please let me know about your experiences (Good and Bad).


    I don't think those good people in Seatle will be discontinuing asp anytime soon but the .net framework seems to offer a lot more in terms of built in controls and is a bit more extensible.

    alan:cool:

    :D


Advertisement