S
Scott M.
How can I know that user has closed any of the pages,
You can't know.
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.
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
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.
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
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