468,251 Members | 1,390 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,251 developers. It's quick & easy.

Several questions

Hello,
I am using Microsoft Visual Studio 2003 .NET.

I have several question, please.

1) I have a connection to the database, which I create it at login,
by application("conMain") (I have some problems by using
session("conMain"), see question 2).

I don't know if it's a good thing to do, and not oppenning at each page the
connection (do I have to open and close a conneciton on each page, or not,
but programming carefully - if so then how shall I program ?) but I want to
know if :

How can I know that user has closed any of the pages, and I should close the
connection (what that happens, is that it's a oleDBConnection to *.mdb file,
and the *.mdb database stay openned, and when I open it in access
enviornment, it is at read only state).

Dialog-Box
---------------
2) I see that when I use dialog-box (by window.showModalDialog), and the
dialog is an aspx page - it opens a new session,
can I stay at the same session as before ?
(I see that parameter Session("aaa") which is known in the calling form, is
unknown at the called dialog box) ?
3) What is the command to close the dialog box ?
4) Dialog box has status bar - can I hide it ? can I put my own text on the
status bar (at the bottom line) ?
5) How can I do refresh to the calling form that called the dialogbox just
after it called it ? (calling form is an aspx page).
6) How can I return the window.dialogArguments, when the dialog-box is an
aspx page ?
------
7) How can I do updates to a query with oleDBCommand (the database is mdb).
I did :
dim cmd as oleDBCommand
.....

cmd.executeNoneQuery
....

What I get that it a message something like : ... not an update query ....
I run the query in the access enviornment, and it looks fine.
What may be wrong ?

8) I have a frameset, that linked to several aspx pages. one of the tabs is
780px width, and is linked to aspx page.
I need that the aspx page will be always 770px.
I cannot see the contour of the width and height when I open the page, and I
could find any automatic method that set always 770px in a new page.
Can I make a default width & height, or is there any simple method to limit
the size of any of the pages, and see immediatelly what happens on the
parent frameset page ?
9) I have an sln project, and for reason I don't know, now I cannot see the
sources of html pages, in a single one page.
What I see is only one of the sources of the pages (i.e main.htm) and I need
each time to double click on the relevant page on the sln explorer, in
oreder to see it.
What's wrong.

Thanks )


Nov 19 '05 #1
9 1131
> How can I know that user has closed any of the pages,

You can't know.
and I should close the connection (what that happens, is that it's a
oleDBConnection to *.mdb file, and the *.mdb database stay openned, and
when I open it in access enviornment, it is at read only state).
Any server side-code you write will be completed BEFORE the user ever gets
the page to look at in their browser. Therefore, you should always open
your connection early on in your page's processing (like Page_Load), do
whatever work you need to do and then close the connection when your work is
done. It has absolutely nothing to do with the page the user gets in their
browser. By the time they get the results of your code, your database
connection will have already been closed.

I see that you are still using the classic ASP applicatoin variables and
session variables. While both still work ASP.NET provides much more robust
ways to persist state. IMHO: you should stay away from these.
7) How can I do updates to a query with oleDBCommand (the database is
mdb).
I did :
dim cmd as oleDBCommand
....

cmd.executeNoneQuery
...

What I get that it a message something like : ... not an update query ....
I run the query in the access enviornment, and it looks fine.
What may be wrong ?
Your code above does not create an instance of anything because the keyword
"new" is not being used. Even if you had used it, you haven't configured
your command's CommandText (like a SQL statement or stored procedure name),
so your command has no idea what it is supposed to do when you call an
execute method. You also haven't configured the command to know what
connection it should use. Don't take this the wrong way, but this is pretty
fundamental ADO.NET stuff. You should really spend some time at
msdn.microsoft.com or ASP.NET or pick up a book on ASP.NET/ADO.NET.

This is more like what you need:

Dim conStr As String = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" &
Server.MapPath("relative path to your database here")
Dim con As New OleDb.OleDBConnection(conStr)

Dim cmdStr As String = "SQL Statement Here"
Dim cmd As New OleDb.OleDbCommand(cmdStr, con)
Dim retVal As Integer

Try
con.Open
retVal = cmd.ExecuteNonQuery
Catch ex As OleDBException
'Handle database exceptions here
Catch ex2 As Exception
'Handle other exceptions here
Finally
con.close
End Try
8) I have a frameset, that linked to several aspx pages. one of the tabs
is 780px width, and is linked to aspx page.
I need that the aspx page will be always 770px.
I cannot see the contour of the width and height when I open the page, and
I could find any automatic method that set always 770px in a new page.
Can I make a default width & height, or is there any simple method to
limit the size of any of the pages, and see immediatelly what happens on
the parent frameset page ?
Web pages do not have a size at all, you can't set it the way you are
asking. It is up to you to make sure you do not put any content wider than
the boundry you don't wish to cross. The best way to do this is to create a
new, fresh, blank web page and place a 1 row, 1 column table on it that is
770px wide with the border turned off. Then, you build your web page inside
this table, making sure not to put anything into it that is wider than
770px.

9) I have an sln project, and for reason I don't know, now I cannot see
the sources of html pages, in a single one page.
What I see is only one of the sources of the pages (i.e main.htm) and I
need each time to double click on the relevant page on the sln explorer,
in oreder to see it.
What's wrong.


It doesn't sound like anything is wrong. Each page should open up in its
own code window as you double click it from the Solution Explorer. They are
different files. Why would you expect to see the HTML from different files
in one page?

-Scott
Nov 19 '05 #2
Thanks a lot.
some clarifications :
Any server side-code you write will be completed BEFORE the user ever gets
the page to look at in their browser. Therefore, you should always open
... Should I also close the connection on each ASPX page, or is it close
automatically ?

Your code above does not create an instance of anything because the
keyword "new" is not being used. Even if you had used it, you haven't
configured your command's CommandText (like a SQL statement or stored
procedure name), ... Thank you.

My code was just fine (it was in the three dots)
What I did wrong, I see due your code :
I did :
call cmd.executeNoneQuery
instead of
retVal = cmd.executeNoneQuery.
That's all.
Web pages do not have a size at all, you can't set it the way you are
asking. It is up to you to make sure you do not put any content wider
than ....
Thank you.
It doesn't sound like anything is wrong. Each page should open up in its
own code window as you double click it from the Solution Explorer. They
are different files. Why would you expect to see the HTML from different
files in one page?


You understood me wrongly.
There should be a page-tab (like you see at bottom of each *.xls
excel-file).
What I see is not a page tab, that before I saw it.

Another things are my questions to dialog.
Also : I created a dialog, which is an aspx page.
How can I force "killing" from memory the dialogbox.
I have a problem that the calling form remember the dialogbox, and whenever
I open the dialog again,
I don't even get into the form_load event (before the if statement, of
course).
Also my questions about dialog-box have no answers yet :
Dialog-Box
---------------
2) I see that when I use dialog-box (by window.showModalDialog), and the
dialog is an aspx page - it opens a new session,
can I stay at the same session as before ?
(I see that parameter Session("aaa") which is known in the calling form, is
unknown at the called dialog box) ?
3) What is the command to close the dialog box ?
4) Dialog box has status bar - can I hide it ? can I put my own text on the
status bar (at the bottom line) ?
5) How can I do refresh to the calling form that called the dialogbox just
after it called it ? (calling form is an aspx page).
6) How can I return the window.dialogArguments, when the dialog-box is an
aspx page ?

Thanks :)
Nov 19 '05 #3
>> Any server side-code you write will be completed BEFORE the user ever
gets the page to look at in their browser. Therefore, you should always
open ... Should I also close the connection on each ASPX page, or is it close
automatically ?


You should open it in each page, do the work you need to do and close it (no
it is not closed automatically [unless you are using a DataAdapter, which it
sounds like you are not]) on each page.
Your code above does not create an instance of anything because the
keyword "new" is not being used. Even if you had used it, you haven't
configured your command's CommandText (like a SQL statement or stored
procedure name), ...

Thank you.

My code was just fine (it was in the three dots)
What I did wrong, I see due your code :
I did :
call cmd.executeNoneQuery
instead of
retVal = cmd.executeNoneQuery.
That's all.


Well, you said that you were getting an error and you didn't provide all
your code, so I assumed that what you did provide was all you wrote. My
retVal variable does not need to be included to prevent your error. It's
just there to get the return value (of how many records are affected by the
command).

Web pages do not have a size at all, you can't set it the way you are
asking. It is up to you to make sure you do not put any content wider
than ....


Thank you.
It doesn't sound like anything is wrong. Each page should open up in its
own code window as you double click it from the Solution Explorer. They
are different files. Why would you expect to see the HTML from different
files in one page?


You understood me wrongly.
There should be a page-tab (like you see at bottom of each *.xls
excel-file).
What I see is not a page tab, that before I saw it.


Try going into Tools...Options and on the first section, hit the Reset
Window Layout button and look again.
Also my questions about dialog-box have no answers yet :
Dialog-Box


I didn't answer the dialog box questions because I didn't understand them.
You have to remember that all the code in an .aspx page is server-side code.
That is, code that is processed on the server BEFORE the client recieves the
page. Generally speaking, you don't use dialog boxes on web pages. You use
them in a Windows Forms application.

Nov 19 '05 #4
Thank you for all your answers.
Except the dialog box, all answered were replied - thank you very much.

For the dialog-box :

In the asp page, I have linked a datagrid to a table (users).
The datagrid is called : dsUsers.

In the ItemDatabound event, I add the event of some of my edit button, to do
: open a dialog box.
(So, I persume this happens before the code is send to client,
and that's how on aspx, I call another aspx form, that is in a dialog box.
Also the code is web project, that is under the sln applications,
and under that project, there are pages, such as aspx, etc...,
so it is a web project, that I can run at the internet, isn't it ?)

Here is the code :
-----------------------

Private Sub dgUsers_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgUsers.ItemDataBound
Dim editBtn As LinkButton

Dim btn As Button

Dim s As String

If e.Item.ItemIndex <> -1 Then

If e.Item.ItemType = ListItemType.Item Or ListItemType.AlternatingItem Then

btn = CType(e.Item.Cells(0).Controls(0), Button)

s = e.Item.Cells(8).Text

btn.Attributes.Add("onclick", _

String.Format("window.showModalDialog('myAspPage.a spx?user_id=" & s & "',
'', 'dialogHeight:575 ;dialogWidth:600px;center=yes')"))

-----------

It also works, and open the dialog.
The related dialog box is for myAspPage.aspx.
The related caling aspx is myCallAsp.aspx.

Now, again let's return to the questions about dialog, I have asked.

Thanks :)
Nov 19 '05 #5
I think you are going about the Edit button incorrectly. There is no need
to register an event handler for a link button at all. Just add a Button
column to the DataGrid and your grid will respond to the edit linkButton's
click automatically with the EditCommand event handler. The grid will then
automatically switch into "edit mode" so the user can edit the data. There
is no need for a dialog box at all.

Here's the HTML for the DataGrid:

<asp:DataGrid id="DataGrid1" runat="server">
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton"
UpdateText="Update"
CancelText="Cancel"
EditText="Edit">
</asp:EditCommandColumn>
</Columns>
</asp:DataGrid>

And, here's the code-behind code to handle the clicking of the button:

Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.EditCommand

End Sub

And yes, as I've said, ALL server-side code is execute BEFORE the client
(browser) ever gets anything. Also, if you have .aspx pages, then yes, you
are making a web application which runs over the Internet.
"Eitan" <no****@nospam.com> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
Thank you for all your answers.
Except the dialog box, all answered were replied - thank you very much.

For the dialog-box :

In the asp page, I have linked a datagrid to a table (users).
The datagrid is called : dsUsers.

In the ItemDatabound event, I add the event of some of my edit button, to
do : open a dialog box.
(So, I persume this happens before the code is send to client,
and that's how on aspx, I call another aspx form, that is in a dialog box.
Also the code is web project, that is under the sln applications,
and under that project, there are pages, such as aspx, etc...,
so it is a web project, that I can run at the internet, isn't it ?)

Here is the code :
-----------------------

Private Sub dgUsers_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgUsers.ItemDataBound
Dim editBtn As LinkButton

Dim btn As Button

Dim s As String

If e.Item.ItemIndex <> -1 Then

If e.Item.ItemType = ListItemType.Item Or ListItemType.AlternatingItem
Then

btn = CType(e.Item.Cells(0).Controls(0), Button)

s = e.Item.Cells(8).Text

btn.Attributes.Add("onclick", _

String.Format("window.showModalDialog('myAspPage.a spx?user_id=" & s & "',
'', 'dialogHeight:575 ;dialogWidth:600px;center=yes')"))

-----------

It also works, and open the dialog.
The related dialog box is for myAspPage.aspx.
The related caling aspx is myCallAsp.aspx.

Now, again let's return to the questions about dialog, I have asked.

Thanks :)

Nov 19 '05 #6
> Here's the HTML for the DataGrid:

<asp:DataGrid id="DataGrid1" runat="server">
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton"
UpdateText="Update"
CancelText="Cancel"
...


No !!!
I know that kind option, but I don't want to ...

I want to open a dialog box for kind of reason,
and I need the code behinds.

Why not just answer my several questions, as before.
Again (the same forgotten 6 questions) :

Dialog-Box
---------------
2) I see that when I use dialog-box (by window.showModalDialog), and the
dialog is an aspx page - it opens a new session,
can I stay at the same session as before ?
(I see that parameter Session("aaa") which is known in the calling form, is
unknown at the called dialog box) ?
3) What is the command to close the dialog box ?
4) Dialog box has status bar - can I hide it ? can I put my own text on the
status bar (at the bottom line) ?
5) How can I do refresh to the calling form that called the dialogbox just
after it called it ? (calling form is an aspx page).
6) How can I return the window.dialogArguments, when the dialog-box is an
aspx page ?
------

Thanks :)
Nov 19 '05 #7
I have told you why I haven't answered your dialog questions. Because I
don't have too much information about this particular method.
"ShowModelDialog" is an IE proprietary method of the client-side "window"
object. I don't use proprietary objects, properties and methods.

I can tell you that whenever you open a new browser window, you get a new
session. There is nothing you can do about that.

A simple msdn search reveals quite a bit of information
(http://msdn.microsoft.com/library/de...odaldialog.asp)

Among other things, this url explains how to pass data into this window.

In additon, the JavaScript command to close the current window is:
self.close()

"Eitan" <no****@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Here's the HTML for the DataGrid:

<asp:DataGrid id="DataGrid1" runat="server">
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton"
UpdateText="Update"
CancelText="Cancel"
...


No !!!
I know that kind option, but I don't want to ...

I want to open a dialog box for kind of reason,
and I need the code behinds.

Why not just answer my several questions, as before.
Again (the same forgotten 6 questions) :

Dialog-Box
---------------
2) I see that when I use dialog-box (by window.showModalDialog), and the
dialog is an aspx page - it opens a new session,
can I stay at the same session as before ?
(I see that parameter Session("aaa") which is known in the calling form,
is
unknown at the called dialog box) ?
3) What is the command to close the dialog box ?
4) Dialog box has status bar - can I hide it ? can I put my own text on
the
status bar (at the bottom line) ?
5) How can I do refresh to the calling form that called the dialogbox just
after it called it ? (calling form is an aspx page).
6) How can I return the window.dialogArguments, when the dialog-box is an
aspx page ?
------

Thanks :)

Nov 19 '05 #8

"Scott M." <s-***@nospam.nospam> wrote in message
news:OO*************@TK2MSFTNGP12.phx.gbl...
I have told you why I haven't answered your dialog questions. Because I
don't have too much information about this particular method.
Well, say so.
I can tell you that whenever you open a new browser window, you get a new
session. There is nothing you can do about that.

A simple msdn search reveals quite a bit of information
(http://msdn.microsoft.com/library/de...odaldialog.asp)

Among other things, this url explains how to pass data into this window.

In additon, the JavaScript command to close the current window is:
self.close()


Thanks :)
I'll go that link.
Nov 19 '05 #9

"Eitan" <no****@nospam.com> wrote in message
news:uN*************@TK2MSFTNGP09.phx.gbl...

"Scott M." <s-***@nospam.nospam> wrote in message
news:OO*************@TK2MSFTNGP12.phx.gbl...
I have told you why I haven't answered your dialog questions. Because I
don't have too much information about this particular method.


Well, say so.


I did. Just go back and look at my responses.
Nov 19 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by michela rossi | last post: by
1 post views Thread by Torsten Mohr | last post: by
reply views Thread by Victor Porton | last post: by
1 post views Thread by Ayende Rahien | last post: by
2 posts views Thread by Tiago Miguel Silva | last post: by
1 post views Thread by Joe | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.