|
I am building datasets at run time from asn asp.net c# web page. My chalenge is one of my stored proceedures has to harvest an extremely large dataset depending on the date range selected. My question is how to I set the progress of the stored proceedure?
Here is a scenario
if the data range is this month or this week the proceedure will run in a small period of time maybe 15 seconds. But if they choose to run the dataset going back one full year then it will take atleast 5 mins to generate the appropriate data.
How to I make the asp.net webpage wait until that proceedure is done?
Thanks
|
|
|
|
|
wait how ? Your page is going to timeout in five minutes. Your best bet is to have another process, such as a windows service, do the stored proc call, and have your page auto postback, or use AJAX, to work out when the process has ended, and the data can be loaded by the page.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I added an attribute to the items of a DropDownList.
cbBudget.Items(0).Attributes.Add("bLocked", true)
cbBudget.Items(1).Attributes.Add("bLocked", false)
Now I want to get the value of the selected item in the DropDownList using javascript.
I tried something like this:
document.getElementById("cbBudget").selectedItem.getAttribute("bLocked")
but it doesn't work.
The source looks like this:
Class1
Class 2
Thank you for your suggestions.
|
|
|
|
|
|
This also worked
var index =document.getElementById("cbBudget").selectedIndex;
alert(document.getElementById("cbBudget").options[index].bLocked)
Thanks Ben
|
|
|
|
|
Thanks Ben,
That is a great article, now I don't have to Alert("I am here"); anymore.
Martin
|
|
|
|
|
Glad you liked it. Without it I don't think I would have gotten into javascript. Too much like the old Cobol programming I used to have to do with the "I am here" to debug.
Ben
|
|
|
|
|
Hi
I have built a simple page which will should send a persons firstname and lastname to mysql database, i am not sure how to code the submit button as i obviously need it to call my method for sending data to the server based on the input in my text boxes.
Any suggestions, i recognise is probably fundamental but am newbie to asp and not got much web development background
This is what I have
<%@ Page Language="VB" debug="true" %>
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "MySql.Data.MySqlClient" %>
<script language="VB" runat="server">
Sub page_load()
End Sub
''' <summary>
''' Page_load
''' Recognised by ASP and must be provided on loading of page.
'''
''' Creates connection to database, passes stored procedure into test database
''' and fills a table, which is showing in web browser
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Sub sendData(ByVal sender As Object, ByVal e As EventArgs)
'Create connection string to pass database, string holds login information to mySQL,
Dim connectionString As String
connectionString = "Server=; uid=; pwd=;database=;"
'Builds .net mysql connection and passes connection string into method
Dim connection As New MySqlConnection(connectionString)
'Open connection to DB
connection.Open()
'Create mySql command string for passing query or SPROC(Stored Procedure)
Dim cmdString As New MySqlCommand
'Set Command to equal mySql connection,t so can pass SQL query
cmdString.Connection = connection
'Set command string to equal SPROC
cmdString.CommandText = "insertmessage"
'ONLY PLACE THIS IF SPROC, sets the command to a SPROC
cmdString.CommandType = CommandType.StoredProcedure
Dim param As New MySqlParameter
param = cmdString.Parameters.Add("param1", SqlDbType.VarChar, 50)
param.Direction = ParameterDirection.Input
param.Value = txtFirstName.Text
param = cmdString.Parameters.Add("param2", SqlDbType.VarChar, 50)
param.Direction = ParameterDirection.Input
param.Value = txtLastName.Text
cmdString.ExecuteNonQuery()
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script language="vbscript" type="text/vbscript">
</script>
</head>
<body>
<form id="form1" runat="server">
ENTER FIRSTNAME<asp:TextBox runat="server" ID="txtFirstName">
</asp:TextBox><br /><br />
ENTER LAST NAME
<asp:TextBox runat="server" ID="txtLastName"></asp:TextBox>
<asp:Button runat="server" ID="submit" Text="Submit" />
</form>
</body>
</html>
|
|
|
|
|
Other than hard coding your connection string, rather than placing it in the web.config file, I think you've got the right idea.
only two letters away from being an asset
|
|
|
|
|
Two things:
1) It looks as though you are not using Visual Studio, but have your server code inline - ie in the same file - as you have pasted it here. In this case you need to let the page know which procedure is to be associated with the button click event. Like this:
<asp:Button runat="server" ID="submit" Text="Submit" onclick="sendData" />
2) Within your sendData procedure, you must remember to close the database connection after use. Really, you ought to wrap the code in a try...catch...end try block - something like:
try
connection.Open()
' do your db stuff...
connection.CLose()
catch
If connection.State = ConnectionState.Open Then connection.Close()
end try
cheers
Fred
|
|
|
|
|
I have made the necessary changes as you have said above, it jus keeps falling through to the catch statement tho
any more suggestions?
I have debugged and it seems to go thru as expeced also
<%@ Page Language="VB" debug="true" %>
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "MySql.Data.MySqlClient" %>
<script language="VB" runat="server">
Sub page_load()
End Sub
''' <summary>
''' Page_load
''' Recognised by ASP and must be provided on loading of page.
'''
''' Creates connection to database, passes stored procedure into test database
''' and fills a table, which is showing in web browser
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Sub sendData(ByVal sender As Object, ByVal e As EventArgs)
Try
'Create connection string to pass database, string holds login information to mySQL,
Dim connectionString As String
connectionString = "Server=localhost; uid=jshort; pwd=oasisarab;database=test;"
'Builds .net mysql connection and passes connection string into method
Dim connection As New MySqlConnection(connectionString)
'Open connection to DB
connection.Open()
'Create mySql command string for passing query or SPROC(Stored Procedure)
Dim cmdString As New MySqlCommand
'Set Command to equal mySql connection,t so can pass SQL query
cmdString.Connection = connection
'Set command string to equal SPROC
cmdString.CommandText = "insertmessage"
'ONLY PLACE THIS IF SPROC, sets the command to a SPROC
cmdString.CommandType = CommandType.StoredProcedure
Dim param As New MySqlParameter
param = cmdString.Parameters.Add("param1", SqlDbType.VarChar, 50)
param.Direction = ParameterDirection.Input
param.Value = txtFirstName.Text
param = cmdString.Parameters.Add("param2", SqlDbType.VarChar, 50)
param.Direction = ParameterDirection.Input
param.Value = txtLastName.Text
cmdString.ExecuteNonQuery()
connection.Close()
Catch
MsgBox("Broken")
End Try
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script language="vbscript" type="text/vbscript">
</script>
</head>
<body>
<form id="form1" runat="server">
ENTER FIRSTNAME<asp:TextBox runat="server" ID="txtFirstName">
</asp:TextBox><br /><br />
ENTER LAST NAME
<asp:TextBox runat="server" ID="txtLastName"></asp:TextBox>
<asp:Button runat="server" ID="submit" Text="Submit" onclick="sendData" />
</form>
</body>
</html>
|
|
|
|
|
Add a literal control to the page (anywhere)
<asp:Literal runat="server" id="litErr" />
Then replace the catch bit with
catch ex as exception
litErr.Text = ex.Message
That should give you a better idea of where the error is...
cheers
Fred
|
|
|
|
|
on debugging it says that my parameter thats being passed to the stored procedure isn't defined, which i don't understand as i have it defined within the procedure.
This is the code from my procedure
CREATE DEFINER=`myusername`@`localhost` PROCEDURE `InsertMessage`(IN param1 VARCHAR(50), IN param2
VARCHAR(50))
BEGIN
INSERT INTO names(firstName, lastname)
VALUES(param1,param2);
END
|
|
|
|
|
Don't paramater names in SP's have to start with an @ sign? I think so...
Add these to your SP and don't forget to amend your vb code accordingly...
Fred
|
|
|
|
|
Hi All,
Please help me...
I want Import and Export data from excel or access to Sql Server from software
Language: asp.net using Vb
version:.Net 2005
Thank you..
|
|
|
|
|
Are you asking for help in doing this or posting a job requirement?
If the former, what have you done so far? If the latter, wrong forum.
only two letters away from being an asset
|
|
|
|
|
Hi,
i am building a application in which user register with our website.
As soon as he register an entry of his email address is made in database table.
Now I have to send him a mail as soon as he register .
i have build a console program to send him mail by picking emailaddress from DB table.
But I want to make my email program autoresponding means as soon as any user sign up an email is sent to him..
How can I do that..Plz provide me answer it is very crucial..
hiiiiii
|
|
|
|
|
hkchauhan wrote: have build a console program to send him mail by picking emailaddress from DB table
So you have the code to extract and send the email. What part are you missing?
only two letters away from being an asset
|
|
|
|
|
hkchauhan wrote: i have build a console program to send him mail by picking emailaddress from DB table.
You don't need this application. You can send mail from the Register page itself. You have to send the mail after the data is stored in to the Database.
|
|
|
|
|
Hi,
I have to upload a file, and I saw hat you must specify the form attributes like:
<form Method="Post" EncType="Multipart/Form-Data" RunAt="Server">
But I have a little problem. I am using master pages, and I have my <form></form> specified in the master page.
What do I do now?
ma se
|
|
|
|
|
Hi ma se,
I want to tell you that you dont need to include EncType in your code for uploading file.
You can use fileuplaod control for uploading any file..
I may be wrong but i never use EncType for uploading file.
Also you can use fileupload control in master page too.
|
|
|
|
|
Hi,
In a web form, user enters the SQL query in a Multi-line asp TextBox. But the the formatting is such a way that sometimes the Column names gets broken or wrapped.
So while executing, I get error from our data layer. Is there a way to avoid this?
Regards,
Blumen
|
|
|
|
|
I think it is a problem of "" in your string.
But can not say properly.
You should give some more detail
|
|
|
|
|
Viral Upadhyay wrote: You should give some more detail
Example Query:
Select Column_Name1,Column_Name2,Column_Name3 from Table1
The above query (assume its very long) would look something like this in a multi-line asp textbox:
Select Column_Name1,Column
_Name2,Column_Name3 from Table1
So here the columnname 2 is broken, and it causes error in DB.
Blumen
|
|
|
|
|
See it may be because some ecape charactor inserted there so try to remove that charactor may be it works
|
|
|
|