|
val is a declared label to store the data from the NTN column of the grid
Dim val As Label = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
Thanks.
|
|
|
|
|
I suspected that. Probably not a good idea to have a label with the same name as a VB function. I am not saying that this is the cause of your problem, but try renaming that label first. Dim lblNTN As Label would be much more readable.
Actually looking at this, where is this label being created?
Dim val As Label = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
What is control "NTN"?
|
|
|
|
|
As TheComputerGuy said and then try:
Dim lblNTN As New Label
lblNTN = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
My advice is free, and you may get what you paid for.
|
|
|
|
|
Ok guys i tried that, but I am still getting that "Object reference not set to an instance of an object" on the insert statement.
Just want to clarify that "NTN" in
lblNTN = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
is the name of the column of the Data Grid from which I want the data to be retrieved. Am I doing it the correct way? If not please help with this.
Thanks.
|
|
|
|
|
You might as well just forget about the label completely, and try something like this:
cmd1.CommandText = "insert into uu.record_backup(ntn, name, status, enf, aud, sector, delete_user) select ntn, name, status, enf, aud, sector" _
& ",'" & Label5.Text & "'" & " from uu.total_cases where trim(ntn)='" _
& GridView1.Rows(e.RowIndex).Cells("NTN").Value & "'"
My advice is free, and you may get what you paid for.
|
|
|
|
|
Ok guys "GridView1.Rows(e.RowIndex).Cells("NTN").Value" gives error on the "value" as it does not recognize it. So I used "GridView1.Rows(e.RowIndex).Cells("NTN").Text". Now I am getting the following error
System.FormatException: Input string was not in a correct format.
it is coming on this line.
Line 54: cmd1.CommandText = "insert into uu.record_backup(ntn, name, status, enf, aud, sector, delete_user) select ntn, name, status, enf, aud, sector,'" + Label5.Text + "' " + "from uu.total_cases where trim(ntn)='" + GridView1.Rows(e.RowIndex).Cells("NTN").Text + "'"
Please help me where I am making mistake in the above line.
Thanks for your help.
|
|
|
|
|
Hi all, i want to retrieve value from dataset. I build dataset from sql data adapter,
Dim strSQL As String
strSQL = "select name FROM sysobjects WHERE xtype='U' and name = 'OPEX" & Str(jumtbl) & "'"
Dim dachecktable As SqlDataAdapter = New SqlDataAdapter(strSQL, oConnection)
Dim dschecktable As New DataSet
dachecktable.Fill(dschecktable, "DSchecktable")
If dschecktable.Tables(0).Rows.Count > 0 Then
----> how can i retrive the item data from dataset dschecktable
' strSQL = "drop table "
End If
Thanks in advance
|
|
|
|
|
What have you tried ? What does MSDN say ?
You already have the code to check if there's rows in the table ( although it does assume one table exists ). You can foreach over the rows, or address them by index. Then for each row, you can index fields or address them by name
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I found it at last, i have to create datarow first, this what i got, advice me if there is better way.
Thank you
|
|
|
|
|
you don't *create* a datarow, you iterate over the ones that are already in your table.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Once you get populated dataset all you need is to first get corrosponding table and then you can either iterate over rows of table or try find method available on DataTable. For example
DataTable dataTable = dataSet.Tables[0];<br />
foreach(DataRow dataRow in dataTable.Rows)<br />
{<br />
Response.Write(dataRow["column_name"].ToString());<br />
}
|
|
|
|
|
Hi to all.
I have a little problem with a cicle For-Next:
Reduced sample of my code:
For A = 1 To B
If "Condition" = True Then
B = B - 1
End If
Next
This apparently simple code works correctly until A is less than 50 (half cicle, then it cause an error.
I understood that the problem is that the variables B is initially set to the specified value 100 and it is not updated during the cicle For.
I can't use a cicle Do-loop.
I can't predict the final value of B.
How I can resolve the problem?
Thanks
modified on Wednesday, September 2, 2009 5:03 PM
|
|
|
|
|
I'm not sure exactly what you want your end result to be, but I'm wondering if it's not this:
B = 100<br />
For A = 1 To 100<br />
If "Condition" = True Then<br />
B = B - 1<br />
End If<br />
Next
If you always want it to loop 100 times, just set it to 100. Or if that varies as well, just setup another variable to hold the value you are looping to. Like this:
B = 100<br />
C = 100<br />
For A = 1 To C<br />
If "Condition" = True Then<br />
B = B - 1<br />
End If<br />
Next
|
|
|
|
|
Thanks for reply.
Excuse me,
In the sample I assumed B = 100 only for exsample, but in reality the initial value of B is variable.
B rapresents the total records of a file, and initially it's unpredictable.
During the cicle for these records will be reduced to an unpredictable value.
modified on Wednesday, September 2, 2009 5:16 PM
|
|
|
|
|
So does this work for you?
B = 100<br />
C = 100<br />
For A = 1 To C<br />
If "Condition" = True Then<br />
B = B - 1<br />
End If<br />
Next
Or is there a problem that I'm not understanding? If you're still having trouble, it would help us to know more about the end result your looking for.
|
|
|
|
|
The following is the code:
Dim TotRecords As Integer = WptFile.GetLength(0) - 1
Dim TotRecords1 As Integer = WptFile1.GetLength(0) - 1
Dim Index, Index1 As Integer
For Index1 = 1 To TotRecords1
For Index = 1 To TotRecords
If WptFile1(Index1) = WptFile(Index) Then
WptFile1(Index1) = Nothing
Exit For
End If
Next
If WptFile1(Index1) = Nothing Then
WptFile1(Index1) = WptFile1(WptFile1.GetLength(0) - 1)
ReDim Preserve WptFile1((WptFile1.GetLength(0) - 1) - 1)
TotRecords1 = WptFile1.GetLength(0) - 1
End If
Next
TotRecords is the number of records contained in array WptFile
TotRecords1 is the number of records contained in array WptFile1
Array WptFile1 may contain duplicate records of Array WptFile.
I want obtain to reduce the size of Array WptFile1 after deleted from it all duplicate records.
Above code is written for .Net Compact Framework devices.
Thanks
|
|
|
|
|
Hi,
did you consider using generic lists instead of arrays? They might offer you a very useful flexibility and are easy to manage. The following code shows you the dupes - and if you can define your arrays as generic lists from the start, you only need the for-next part:
Public Sub Main()
Dim inArr1() As String = {"Brachiosaurus", "Amargasaurus", "Mamenchisaurus"}
Dim inArr2() As String = {"Tyrannosaurus", "Amargasaurus", "Brontosaurus"}
Dim arr1 As New List(Of String)(inArr1)
Dim arr2 As New List(Of String)(inArr2)
Dim msg As String = "List 2 contains dupes: "
For i = 0 To arr1.Count - 1
If arr2.Contains(arr1.Item(i)) Then
msg &= ", " & arr1.Item(i)
End If
Next
MsgBox(msg)
End Sub
Generic lists also offer a 'remove' method!
Regards
Mick
|
|
|
|
|
Hi,
After some test, I deciced to use normal Arrays (instead ListArrays, because the firsts are a little more fast in intensive use.
Normal Arrays, also allow to re-dimension the size preserving data (ReDim Preserve).
I must try to use others cicles (While..., Do...., etc.)
Regards
Ignazio
|
|
|
|
|
Thanks to all,
I resolved with following code:
Dim TotRecords As Integer = WptFile.GetLength(0) - 1
Dim Index As Integer
Dim Index1 As Integer = 1
Do Until Index1 = WptFile1.GetLength(0)
For Index = 1 To TotRecords
If WptFile1(Index1) = WptFile(Index) Then
WptFile1(Index1) = WptFile1(WptFile1.GetLength(0) - 1)
ReDim Preserve WptFile1((WptFile1.GetLength(0) - 1) - 1)
Index1 = Index1 - 1
Exit For
End If
Next
Index1 = Index1 + 1
Loop
It cuts (re-dimension) array WptFile1, after deleted all duplicated records.
Regards
Ignazio
|
|
|
|
|
Hi all,
I'm learning about printing and have made good progress but there is one thing I can't understand:
I want to set the paper size to a standard size = A4.
I can do it using "papersize" - but is it better to use "paperkind" - if so, how do I do it?
I'm using the full version of visual studio 2008
Thanks for your help and advice....
Regards,
Steve
Thanks for your help and advice!
Steve
|
|
|
|
|
From a very quick glance through some of the documentation, you should use PaperSize .
PaperKind is an enumeration used to provide the options for the PaperSize.Kind property.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Henry,
Thanks for that.............
Steve
Thanks for your help and advice!
Steve
|
|
|
|
|
I am trying to convert a dat file that contain a data records to a text file, the format of the .dat is like this; f]FÓ>
×%0!4 b†ÿÿÿÿÿÿÿÿ!‘RˆOÿÿÿÿÿÿ! ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
F $8 ø b
#Eg_ÿÿÿÿÿÿÿÿ ÿÿÿÿ ÿÿÿÿÿÿÿÿ g]FÔ>
×%0!4 b†ÿÿÿÿÿÿÿÿ!‘RˆOÿÿÿÿÿÿ! ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ#CB(oÿÿb B(oM¡
—§
F %8 b
#Eg_b
#Eg_ ÿÿÿ , € ÿÿÿÿÿÿÿÿ
h]FÕ>
×%8!"
I9ÿÿÿÿÿÿÿÿ!)`†ÿÿÿÿÿÿ! ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
F &8 ø b
#Eg_ÿÿÿÿÿÿÿÿ ÿÿÿÿ ÿÿÿÿÿÿÿÿ i]FÖ>.
Please how can I convert such format.
Thank you.
Thayhor
|
|
|
|
|
You need to know the record layout of the file. It appears that the file contains binary information that you would need to convert to text (or whatever). Without knowing the record layout, it would be nearly impossible to decode the information.
You may want to try using a file editor that can display the hex value of each byte in the file and try to make sense out of it, but that's a long shot.
Get the record layout, then you can read the file, byte by byte and make the data meaningful.
|
|
|
|
|
The file looks like it was written in a fixed record, binary format. Without knowing how each record is layed out, what data is where and how big the fields are, it's nearly impossible to decode this with any meaning. You either have to have documentation on the record format or get it from the original soruce code of the app that wrote the file.
|
|
|
|