|
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.
|
|
|
|
|
Not sure if this belongs here or the databases forum.
Interesting little problem this one. I am creating a list (of string) of statements to be inserted into a database table in SQL Compact (v3.1)
listParams.Add("INSERT INTO [SYS_tbl_SelectText] ([SQLTitle],[SQLStatement]) VALUES ('APPTHISTORY','SELECT SDD_tbl_Appointments.AppointmentDate AS [Appt Date], SDD_tbl_Appointments.AppointmentStart AS [Starts], SDD_tbl_Appointments.AppointmentEnd AS [Ends], (SDD_tbl_Employees.FirstName+' '+SDD_tbl_Employees.LastName) AS [With], SDD_tbl_Treatments.Description AS [Treatment], SDD_tbl_Appointments.FullyPaid AS [Paid], SDD_tbl_Appointments.ValueGross AS [Value], SDD_tbl_Appointments.GrossOutStanding AS [Value Outstanding], SDD_tbl_Appointments.GoodsOutstanding AS [Goods Outstanding] FROM SDD_tbl_Appointments INNER JOIN SDD_tbl_Employees ON SDD_tbl_Appointments.EmployeeID = SDD_tbl_Employees.EmployeeID INNER JOIN SDD_tbl_Treatments ON SDD_tbl_Appointments.TreatCode = SDD_tbl_Treatments.ID')")
It goes into the list just fine, but when the contents of the list are executed, this particular one causes an error:
There was an error parsing the query. [ Token line number = 1,Token line offset = 276,Token in error = +SDD_tbl_Employees.LastName) AS [With], SDD_tbl_Treatments.Description AS [Treatment], SDD_tbl_Appointments.FullyPaid AS [Paid], ]
Any ideas how to resolve this? It seems it does not like the +' '+
|
|
|
|
|
I don't know about SQL Compact, though I assume the syntax is standard T-SQL, but from looking at your code you have a select statement inside quotes. Starting from
TheComputerMan wrote: 'SELECT SDD_tbl_Appointments.AppointmentDate
so the +' '+ will act as a terminator for that string.
Try using + CHAR(13) + instead of +' '+ .
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
Hi, yes this is placing a statement text into a database table. There are many ' characters in the statements but I only get a problem when using the +.
Incidentally the identical code in SQL Server 2005 (as opposed to Compact) does not cause a problem - this is where the SELECT statement is used in the same format as part of an execute to create a stored procedure. In this the +' '+ goes straight in with no problem, but I have not tried storing it I must admit, only executing it.
|
|
|
|
|
Hi,
i start my application as standard User and check for updates, if Updates were available then the application restarts with admin rights (process.start) this works fine!
Next I need to uninstall a software
StartInfo.Arguments = Arguments & ProductCode
StartInfo.FileName = "msiexec.exe"
StartInfo.UseShellExecute = True
StartInfo.Verb = "runas"
UninstallProcess.StartInfo = StartInfo
UninstallProcess.Start()
Dim res As Long = WaitForSingleObject(UninstallProcess.Handle, &H4E20)
when the function WaitForSingleObject calls the main process of the update software exit but the msiexec process finished correctly???
I also tried using --> instead of WaitForSingleObject
While UninstallProcess.WaitForExit(100)
Application.DoEvents()
End While
and also tried using a Delegate Function which check if the Process has exited (UninstalledProcess.HasExited)
but nothing worked!!!
Issues with WaitForExit and Delegate Functions are on Vista x32 and Vista x64 systems, when I use WaitForSingleObject this works with Vista x64
On XP i have no problems with the WaitForExit function
Has anybody an idea how i get rid of this issue???
|
|
|
|
|
The only time I've ever run into this, I had to wait for the process to start before calling WaitForExit.
|
|
|
|
|
I have query for insert by parameters
"INSERT INTO Employee (EMPID, FirstName, LastName)VALUES(@EMPID, @FirstName, @LastName)"
Now what I need I want to give a restriction that any "EMPID Is Not Null" and "EMPID <>Space(15)" only can store to the table.
So how to restrict that?
Any Ideas?
Thanks
PARAMU
|
|
|
|
|
It depends how the value that you feed to the @EMPID parameter is created.
Does it come from a query itself or from a textbox or other windows control?
My advice is free, and you may get what you paid for.
|
|
|
|
|
Add a constraint on the [EMPID] column of the [Employee] table;
ALTER TABLE [Employee]
ALTER COLUMN [EMPID] BIGINT NOT NULL
One defines these checks on the table-level, not for each query. This has the advantage that you can write any number of queries, and still have one single check
The other restriction is also done by creating a new check-constraint on the [Employee] table. You can read more on constraints here[^], there's also an example check-constraint on that page.
I are Troll
|
|
|
|
|
my VBA program:
Private Declare Function FunctionA Lib "A.DLL" (ByVal objptr As Long, ByRef B As STRUCTA) As Integer
Private Type STRUCTA
ID(1 To 5) As STRING
Num(1 To 6) As STRING
End Type
...
Dim longa As long
Dim INFO() As STRUCTA
ReDim INFO(4) As STRUCTA
str = FunctionA (longa, INFO(0))
...
C++ program
struct STRUCTA
{
char* ID[5];
char* NumID[6];
}
DLL_EXPORT int __stdcall FunctionA(long a, STRUCTA* IDInfo)
{ ...
IDInfo[0].ID[0] = "123";
IDInfo[1].ID[0] = "456";
...
}
however,the value of INFO(0).ID(0) is "123",but the value of INFO(1).ID(0) is not "456" but "".
I feel only INFO(0)'s value is updated.
why?
how can I do to update INFO(1)-INFO(3)?
help me!
thanks!
|
|
|
|