|
You might want to take a look at creating a view of the Dataset table, filter the view so that it only has the row(s) you want to display in the grid, and then assign the datasource of the grid to the view.
Something like...
Dim dView = New DataView(ds.Tables(3))
dView.RowFilter = "SomeKey = '" & ds.Tables(3).Rows(0)("KeyColumnName") & "'"
datagridview1.DataSource = dView
|
|
|
|
|
Language in use: Visual basic 2008
I am reading a COFF .out file using a binaryreader from within VB. After reading it, I am converting it to hexidecimal format.
However, the structure of the file is not apparent either before the conversion or after it. I am able to actually read some of the ASCII comments within the file. However, I am pretty sure there is address information available within the file along with data, probaby in a hex form or something similar.
Is there an easy way to determine the internal structure "or lack there of"? of a binary file using VB. I am confident this file has internal structure/sections of some sort because I have created a binary file and it is not recognized as a COFF file. Is there or can there be Crlf's within a binary file. If I try to read the file as a text file, all I get is one ASCII symbol "ASCII code 0xC1 or something similar".
I am trying to determine the format because I need to create a customized .out file that contains a serial number only and store that at the proper address location.
Usually, the COFF file is created on a development system and I believe the .out file also contains linker information. In this paritular case, the .out file is for programming a DSP and adding the serial number withn each DSP device. The development station or emulator package is not an option being as the solution needs to be an automated self-contained for use within a production environment.
"old forum members jump to conclusions, while others search for the real solutions."
|
|
|
|
|
Dennis,
Have you looked around on the 'net for anything on COFF files?
Jeff
|
|
|
|
|
Jeff,
Yes, I have spent hours and hours on google looking for information on COFF file formatting along with searching for .OUT and both of the above in every other flavor of search terms I could think of.
I am beginning to think that COFF is a proprietary format or something. The manufacturer of the DSP is Texas Instruments.
Some web sites, I have visited have stated that COFF is an obsolete format that was used back in the Unix days. They may not be talking about the same COFF. It is possible that I am not using the right search parameters. There was one reference to obtaing the coff format at TI but that turned out to be a disabled/dead link.
Dennis
"Life is short and the journey long" -DL
|
|
|
|
|
I recently found some information on the COff file format.
and I have started to parse some of the data from a byte array that holds the file contents.
However, when I display the data byte by byte I get the following as a short example: b5-60-8b-48-
If I do a conversion.hex(bitconverter.ToUint32 _(returnvalue,4)
I get the information reversed which makes sense. 488b60b5 being as the conversion.hex routine is starting at the high byte. I am just not certain this is how it should be interpreted in the file according to the following definition from the COFF format.
So, I do not know if I should be starting with byte 4,5,6,7 or the reverse 7,6,5,4
'---------------------------------
byte
Number Type Description
0–1 Unsigned short Version ID; indicates version of
COFF filestructure
2–3 Unsigned short Number of section headers
4–7 Integer Time and date stamp; indicates when the file
was created
8–11 Integer File pointer; contains the symbol table’s
starting address
12–15 Integer Number of entries in the symbol table
20–21 Unsigned short Target ID; magic number (0099h)
indicates the file can be executed in a C6000 system
xx-xxx (continued for several hundrd bytes...I think)
'----------------------------
Imports Microsoft.Visualbasic.FileIO
Imports System.IO
Imports System.Text
Dim StrTime As String
Dim StrCoff_Ver_ID, StrNum_Section_Headers As String
Dim ReturnValue As Byte()
Dim x as integer
'file is the binary COFF file being read
'Returnvalue is byte array of entire file contents
ReturnValue = FileSystem.ReadAllBytes(file)
x = 0
StrCoff_Ver_ID =
Conversion.Hex(BitConverter.ToUInt16(ReturnValue, x))
x = 4
StrTime =
Conversion.Hex(BitConverter.ToUInt32(ReturnValue, x))
question: can the byte order be easily reversed if neccessary? They refer to "big endian format" in the documentation. I think I know what this format is and how to handle it for a 2 byte chunk of code. (0c d0) However when it gets to a 4 byte chunk like the filesystem var then I'm not sure what the order is (0c d0 1f 4c) is it (1f 4c 0c d0) or (4c 1f d0 0c),etc. ??
modified on Sunday, August 24, 2008 4:41 PM
|
|
|
|
|
Hello !
I'm using SystemParametersInfo API to set desktop work area so 25 pixels on top are free... I do it like this :
SystemParametersInfo(SPI_SETWORKAREA, Nothing, area, SPIF_UPDATEANDSEND)
where SPIF_UPDATEANDSEND = SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE
and everything works! then my program is closed ... and everything stays that way for like 5 minutes. Then work area is restarted to full screen ... What can I do so work area that I set will be remembered at least until reboot ?
thanks
|
|
|
|
|
xx77abs wrote: and everything stays that way for like 5 minutes. Then work area is restarted to full screen ... What can I do so work area that I set will be remembered at least until reboot ?
Keep your code running. Once your code stops, that's it, the area you reserve is returned to the desktop.
|
|
|
|
|
wow, thanks I thought about that, but didn't try to do it ... So after I set workspace area, only thing I need to do is not close my program ...
thanks
|
|
|
|
|
Hiya,
I was just wondering how (if possible) to add a windows form to a DLL in Vb.net? I have searched on the internet for examples but havent found anything useful
Thanks,
Lloyd
P.S. May take me a while to reply, Im away for a while.
Lloyd J. Atkinson
"Logic will get you from A to B, but imagination will take you everywhere" - ALbert Einstein
I look at Microsoft, and turn to my poster on the wall saying: "Bang head here in case of stress".
|
|
|
|
|
You set the project as a dll assembly, and then create forms in the dll. Then make reference to that dll to use the forms. You will have to create the forms in the new project through code references to the dll assembly.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
You certainly can, however your entry point will be a class and not the form. I have a logon DLL that is used by all our apps for authentication, the whole thing (2 forms, 3 classes) is wrapped in a DLL. Works perfectly.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
On the memory side of things, is it better to use the second example versus the first one, or does it not really matter in the end?
How is memory allocated in the two situations? Will the first one create a ton of objects that get cleaned up after they drop out of scope? Will this affect memory and garbage collection?
For i As Integer = 0 To costTable.Rows.Count - 1
Dim row As DataRow = costTable.Rows(i)
'use the data in the row
Next
Dim row As DataRow = Nothing
For i As Integer = 0 To costTable.Rows.Count - 1
row = costTable.Rows(i)
'use the data in the row
Next
modified on Saturday, August 23, 2008 2:08 PM
|
|
|
|
|
I'm not sure, but I think that it doesn't matter ... That they're the same ...
|
|
|
|
|
The generated code for the both examples will be exactly the same, except that the variable will be assigned a null value before the loop in the second example.
The variable is allocated on the stack, which is very cheap. No objects are created, so there is no garbage collection involved at all. The scope of the variable differs between the examples, but that only matters to the compiler. All local variables are always allocated when the stack frame for the method is created, regardless of where in the method the variables are declared.
Unless you need the counter variable for something else, I would recommend that you use ForEach instead:
ForEach row As DataRow in costTable.Rows
'use the data in the row
Next
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks for the excellent explanation.
I understand there are certain precautions to using a foreach, sometimes it can create overhead from an enumerator. Is there an easy way to know the difference?
|
|
|
|
|
The ForEach loop uses an enumerator, however the enumerator is usually a struct so it's allocated on the stack.
The performance difference between a ForEach loop and using a counter is quite small, and it depends on the situation whichever is faster. Unless you have an actual performace problem, you should just use the one that best fits your needs.
Despite everything, the person most likely to be fooling you next is yourself.
modified on Monday, August 25, 2008 6:21 PM
|
|
|
|
|
Hey,
I'm trying to get my program to launch from a file with an associated extension and have the program immediately load that file.
I've already figured out how to register the extensions thanks to the article at http://www.codeproject.com/KB/vb/VBFileAssociation.aspx[^]. If I doubleclick the external file, my app does successfully launch, but I'm having difficulty getting it to actually load the external file.
So far I think my best bet is to use Application.CommandLineArgs, but I'm not having any luck implementing it. I've tried using the following code, but haven't had any success:
Friend myArgument As String = ""
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
myArgument = My.Application.CommandLineArgs(0)
Catch ex As Exception
If myArgument <> "" Then
InputFile(myArgument)
End If
End Try
...
Does anyone have any ideas? Thanks a bunch!
|
|
|
|
|
Why do you have the InputFile() in the Catch block? Just check to see if there is an argument, and if there is get it:
If My.Application.CommandLineArgs.Count > 0 Then
Dim file As String = My.Application.CommandLineArgs(0)
MsgBox(file)
End If
Then you can do whatever you want with it.
|
|
|
|
|
Hello,
How can I avoid connecting to a database through a connection string? Because everytime I change the database location I should set a new connection string with the new location.
Is there a way to avoid this and save the database within the project itself? And keep the connection there no matter where I install the database? Can I still select, update, delete ... from the database?
John,
|
|
|
|
|
you can set connection string in ur web config file
|
|
|
|
|
If only this was for ASP.NET...
|
|
|
|
|
John,
Maybe you should check out SQL Server Compact Edition[^]. "SQL Server Compact is a free, easy-to-use embedded database engine that lets developers build robust Windows Desktop and mobile applications that run on all Windows platforms including Windows XP, Vista, Pocket PC, and Smartphone."
You can also use SQL Server Express Edition (on localhost) and use a connection string that attaches the database each time you want to connect:
Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
|
|
|
|
|
Check the following link out it would be helpful for you:
Secure Connection and Easy transaction Handling^
In the above link the connection string is read through DBConfig.ini and when you change the database location just change it in the ini file and would work perfectly for your web or desktop applications.
|
|
|
|
|
I'd do something different from the other suggestions listed. I'd create a UDL file within your application directory. Your program will read the UDL for the connect string. If you run your app on another computer/domain, you can easily update the connect string through the UDL's GUI (eliminates the possibility of manually entering in the connectstring in a file and making a mistake).
Right click on your desktop and create a .txt file. Rename the file to something like test.udl. Double click it and you'll see what I'm getting at.
There's numerous articles on how to read a udl if you need help.
Cheers!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Store your connection string in the application settings and set all connection objects to the application setting
To store an app setting:
Right click your project > properties > settings > add your connection string
Alexei Rodriguez
|
|
|
|