Re: A question about order of execution?
From: Blaxer (Blaxer_at_discussions.microsoft.com)
Date: 07/15/04
- Next message: Jordan: "fileinfo.copyto fails when called by delegate"
- Previous message: moondaddy: "Re: Need dhtml code to make text glow red from black"
- In reply to: John Saunders: "Re: A question about order of execution?"
- Next in thread: John Saunders: "Re: A question about order of execution?"
- Reply: John Saunders: "Re: A question about order of execution?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 15 Jul 2004 11:08:02 -0700
I do not know if you read through my post, but this does not help me. I put the code in there to illustrate an order of execution issue. It is an example of how to re-create the problem I am having. It dosen't matter if the variable is shared or if it is a session variable or what have you. The situation still exists.
"John Saunders" wrote:
> "Blaxer" <Blaxer@discussions.microsoft.com> wrote in message
> news:4BDDBA8A-A129-4F9A-AFA5-C51875991CCD@microsoft.com...
> > I have a question about what I think is a problem with order of execution
> of some asp.net code. I have searched on this topic and haven't found any
> answeres which leads me to believe that I am not looking for the right
> thing, that being said if someone could help me with this or just point me
> in the right direciton I would appreciate it.
> >
> > The problem is a bit difficult to explain. I have a few examples of where
> this happens but here is a code example that I know, sometimes does not
> function the way I would expect it to.
> >
> >
> > Public Class Page
> > Public Shared Database_Table_Name as String
> >
> >
> > Public Sub Fill_Datagrid()
> >
> > Dim SQL_CMD as SQLCommand = New SQLCommand("Select * from " &
> Database_Table_Name & " where active = 1"
> > Dim DR As SQLDataReader = SQL_CMD.ExecuteDataReader
> > DG.Datasource = SQL_CMD
> > DG.Databind()
> >
> > End Sub
> >
> >
> > Public Sub Button1_Click (byval blah blah) Handles Button1.Click
> >
> > Database_Table_Name = Textbox1.text
> > Fill_Datagrid()
> >
> > End Sub
> >
> >
> >
> > End Class
> >
> > When I execute code LIKE this, I often get a SQL error because the
> Database_Table_Name variable is not set "yet". It is, however, set in the
> sense that if I now set a label to the variable in the button code it
> appears just fine.
> >
> > Now I know good programming would dictate you should pass the table name
> to the function, but this is an example to show my problem, not good
> technique. Again I appreciate any help / explanation anyone can provide.
>
> Why are you using a Shared variable? It will be shared amongst all users of
> your form, whereas Textbox1.Text will only come from the current request.
> Try removing "Shared" and see what happens.
>
> Also, take a look at the following for something else you should change:
>
> "Protecting Against SQL Injection"
> (http://www.winnetmag.com/Article/ArticleID/42216/42216.html)
>
>
> --
> John Saunders
> johnwsaundersiii at hotmail
>
>
>
- Next message: Jordan: "fileinfo.copyto fails when called by delegate"
- Previous message: moondaddy: "Re: Need dhtml code to make text glow red from black"
- In reply to: John Saunders: "Re: A question about order of execution?"
- Next in thread: John Saunders: "Re: A question about order of execution?"
- Reply: John Saunders: "Re: A question about order of execution?"
- Messages sorted by: [ date ] [ thread ]