|
Hi,
I am having problems looping through an array.
I have an arraylist, that has no values to it, once I start a while loop that fills a datareader. Once I get a specific value from a field in the database, I write that value to the arraylist. Once the reader is done, I also want to display the results from the arraylist in a label.
My code:
<br />
dim arrErrors as new Arraylist()<br />
<br />
While (objDr.Read())<br />
objInvoice = New Invoice()<br />
objInvoice.InvoiceDate = objDr(0).ToString<br />
objInvoice.InvoiceNumber = objDr(1).ToString<br />
objInvoice.InvoiceSubHead = objDr(2).ToString<br />
objInvoice.InvoiceTotal = objDr(3).ToString<br />
objInvoice.InvoiceSignoffBy = objDr(4).ToString<br />
objInvoice.InvoiceSubmittedBy = objDr(5).ToString<br />
<br />
<br />
If objInvoice.InvoiceSubmittedBy = "" Then<br />
arrErrors.Add("An error occured retrieving record" & objInvoice.InvoiceNumber)<br />
<br />
Else<br />
<br />
objInvoiceDetails.Add(objInvoice)<br />
End If<br />
<br />
End While<br />
'' I need code here to display the arraylist in an label<br />
<br />
Would really appreciate the help.
|
|
|
|
|
Dim intCount As Integer = 0
Do While intCount < arrErrors.Count
Me.Label1.Text += arrErrors(intCount).ToString
intCount += 1
Loop
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Thanks,
I have one more problem. I do the code in my data access layer. How can I display the arraylist on my aspx page? If I do the following, I still dont see the label with errors...
<br />
'label already in aspx page <br />
Dim lblShowDetails As Label<br />
<br />
Dim intCount As Integer = 0<br />
Do While intCount < arrErrors.Count<br />
lblShowDetails.Text += arrErrors(intCount).ToString<br />
intCount += 1<br />
Loop<br />
|
|
|
|
|
Are you getting any error or simply the data is not being displayed?
Best Regards,
Apurva Kaushal
|
|
|
|
|
No data is being displayed.
I am new to the 3-tier programming method.
Basically my app works as follows:
aspx.vb file
<br />
<br />
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
<br />
Dim strSuccess As String = Invoice.SelectInvoiceToAS400()<br />
<br />
If strSuccess = 1 Then<br />
lblSuccess.Text = "Successfully added to DB2"<br />
Else<br />
lblSuccess.text = "Unsuccessful entries"<br />
End If<br />
<br />
End Sub<br />
<br />
business tier
<br />
Public Shared Function SelectInvoiceToAS400() As Integer<br />
Return ExportXLSDA.SelectInvoiceToAS400()<br />
End Function
data access tier (in short)
<br />
Public Shared Function SelectInvoiceToAS400() As Integer<br />
<br />
Dim arrErrors As New ArrayList()<br />
<br />
Dim objInvoice As Invoice = Nothing<br />
<br />
'Create new dataset to hold information<br />
Dim objInvoiceDetails As New List(Of Invoice)()<br />
Dim objConn As SqlConnection = New SqlConnection(ConnectionString())<br />
Dim objCmd As SqlCommand = New SqlCommand("sp_SelectInvoiceDetails", objConn)<br />
<br />
'Mark the command as a TEXT Select<br />
objCmd.CommandType = CommandType.StoredProcedure<br />
<br />
'Open the connection<br />
<br />
objConn.Open()<br />
<br />
Try<br />
Dim objDr As SqlDataReader = objCmd.ExecuteReader()<br />
<br />
dim arrErrors as new Arraylist()<br />
<br />
While (objDr.Read())<br />
objInvoice = New Invoice()<br />
objInvoice.InvoiceDate = objDr(0).ToString<br />
objInvoice.InvoiceNumber = objDr(1).ToString<br />
objInvoice.InvoiceSubHead = objDr(2).ToString<br />
objInvoice.InvoiceTotal = objDr(3).ToString<br />
objInvoice.InvoiceSignoffBy = objDr(4).ToString<br />
objInvoice.InvoiceSubmittedBy = objDr(5).ToString<br />
<br />
<br />
If objInvoice.InvoiceSubmittedBy = "" Then<br />
arrErrors.Add("An error occured retrieving record" & objInvoice.InvoiceNumber)<br />
<br />
Else<br />
<br />
objInvoiceDetails.Add(objInvoice)<br />
End If<br />
<br />
End While<br />
<br />
Catch ex As Exception<br />
<br />
Dim strExceptionMsg As String = "Error Executing GetAS400InvoiceDetails(): " & ex.Message & "\r\n"<br />
Throw New Exception(strExceptionMsg, ex)<br />
<br />
Finally<br />
objConn.Close()<br />
<br />
End Try<br />
<br />
<br />
Dim intCount As Integer = 0<br />
Do While intCount < arrShowDetails.Count<br />
lblShowDetails.Text += arrShowDetails(intCount).ToString<br />
intCount += 1<br />
Loop<br />
<br />
Return 1<br />
<br />
End Function
|
|
|
|
|
You just check whether data is there in the arraylist or not.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Apurva Kaushal wrote: You just check whether data is there in the arraylist or not.
Ok, I am not sure what you mean by your post?
Can you maybe help me on how to return that array from my dataaccess layer to the aspx page?
|
|
|
|
|
You can send the arraylist as an object and then later cast it as per your requirement.
Best Regards,
Apurva Kaushal
|
|
|
|
|
If the lable exists on the page then the code should be
<br />
me.lblShowDetails.Text += arrErrors(intCount).ToString<br />
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
ToddHileHoffer wrote: me.lblShowDetails.Text += arrErrors(intCount).ToString
It would work if the array and label is on the same page, however the label is in my aspx.vb class, and the array in my datalayer. - basic 3 tier application.
|
|
|
|
|
OK, there are two ways you can handle this. Pass either the label object to the datalayer ByRef. Or return a string from the datalayer to your aspx.vb page. What is the problem?
-- modified at 10:50 Wednesday 23rd August, 2006
A thrid way would be to return the arraylist from your datalayer. If you don't know how to pass variables to and from classes you need to go open up a newb programming book. This is basic stuff man.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Hi,
I managed to return the array as a string from my datalayer to aspx page. Thanks for your help.
|
|
|
|
|
Hi
I'm getting a small problem. I've declared an array variable in javascript which is working fine if the script is with the aspx page. But when I'm separating the same javascript code to another file, then an script error occurs at the decalration location.
In the aspx page it was defined like this:
var Arr = new Array();
-------
-----
other functions-----
when transferring it to a separate javascript file say JavasS.js, it was written as the first line:
var Arr = new Array();
And then the other functions.
Previously it was working fine, but now its throwing javascript error at the said line.
What can be the reason and how to solve it?
Please help.
Thanks in advance.
Irshad Ahmad
|
|
|
|
|
It might be helpful to post the actual error you are getting.
only two letters away from being an asset
|
|
|
|
|
Hi All,
I got some problem with datagrid paging.
I want to show images in grid I did that.But now problem is that if image is having height 180 only two images should be in single page,if image is having height 60 only 6 images should be in single page and remaining should be on nextpage.
I mean I want to know how to set dynamic pagesize.Or any idea u can share with me to solve my problem.
Regards,
Nagraj
|
|
|
|
|
Hello
i'm making a webapplication using Asp.Net1.1 with vb.
By Using my Applicaton User Can Make his Site and Uploaded on his Server as well.
now i have to Monitor his Server by my Application that how many Disk Space he has been used if we allowed him 100 MB.
how can i do it.
thanx
|
|
|
|
|
hi
i installed iis in my system and test it by : http://localhost/localstart.asp and working correctly .
but when i create asp.net web site in VS2005 the following message shown me :
The site 'http://localhost/WebSite1' has not been configured for use with ASP.NET 2.0. Microsoft Visual Studio has been designed for use with ASP.NET 2.0; if not configured some features may make incorrect assumptions, and pages designed with the tool may not render correctly.
Would you like the site to be configured now?
and when i click Yes the follwing message shown me :
Configuring web site 'http://localhost/WebSite1' to ASP.NET 2.0 failed. You may need to manually configure this site for ASP.NET 2.0 in order for your site to run correctly.
and when i compile my project by VS2005 the following message shown me :
Unable to start debugging on the web server. The server does not support debugging of ASP.NET or ATL Server applications. Click Help for more information on how to enable debugging.
You may also want to refer to the ASP.NET and ATL Server debugging topic in the online documentation.
How to Solve my Problem ??
|
|
|
|
|
I am not sure but if you try this,
Go to your IIS server and right click default website and choose properties.
for the tabs choose Asp.net tab
and check which version is there if its not version 2 or later then choose latest version from there . it may help.
thanks
Naveed Kamboh
|
|
|
|
|
Hi
Thanks for guide me . i checked version and it's empty and i set it to 2.X but when i start without debug of my project the following message shown me :
Server Error in '/WebSite1' Application.
----------------------------------------------
Failed to access IIS metabase ...
and not run in debug mode . ow to solve my problem ?? my version iis is 5.1 .
Do u know that i must install IIS 6.0 or higher ?
|
|
|
|
|
This means that ASP.Net is not properly registered with IIS.
.Net framework provides an Administration utility that manages the installation and uninstallation of multiple versions of ASP.NET on a single machine. You can find the file in C:\WINNT\Microsoft.NET\Framework\v**\aspnet_regiis.exe
use the command: aspnet_regiis.exe -u ---> to uninstall current asp.net version.
use the command: aspnet_regiis.exe -i ---> to install current asp.net version.
For Windows Server 2003, you must use aspnet_regiis -i -enable
This is because of the "Web Service Extensions" feature in IIS 6
Thanks & regards,
Suresh Dayma
|
|
|
|
|
here my prob is ,
for example i have a savebutton
and when that button clicked am do both insert and update,
if yes how to do that.using any flag variable or something like that,urgent.
kissy
|
|
|
|
|
Insert and update what? A file, a listbox, database???
only two letters away from being an asset
|
|
|
|
|
And even if both are there they can be done one after one.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hi,
I hope my understanding is correct.
You have button to save the data to the backend, that needs to insert the new record and update the existing reocrd is it? You can have a viewstate variable in your web form to check the corrent record on the web form is in insert mode or update mode (If a record retrieved from backend it is in update mode), set the status as 'U' in the view state, if the viewstate value is 'U' issue an update or make an insert. Hope this what you want?
Ram
|
|
|
|
|
how it will works,i can not get the idea.I have add,update,save buttons.if i add button just i am able to edit a name in the textbox,then i click save.same way if i click on update ,i can just modify the value and again i need to click on save button to save the changes.
will it be possible to do these two tasks in save button(insert,update).how??
kissy
|
|
|
|