|
You found what appears to be VB6 code. The Long type in VB6 is a 32-bit signed integer. In VB.NET, it's a 64-bit signed integer. The two are not interchangable when P/Invoking API functions. In VB.NET, you replace the Longs with Integer.
|
|
|
|
|
yep. He also better use IntPtr for passing pointers, if Win64 is going to be used someday.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi, can we insert/update value to ms access database over network via UDP?
modified on Thursday, March 24, 2011 2:06 AM
|
|
|
|
|
Considering Access is a file-based database, with no communication server at all, it's impossible to do directly. You've have to build some kind of server component to handle all the database access over a network connection of your choice.
|
|
|
|
|
I see...
But, i was asked to develop a client-server applications using Microsoft Access. Is the only way to make connection to access database over the network,just to share the folder where my application is, and the 2nd option is using access database project (ADP) with SQL server? (sorry for my bad english, hope you'll understand)
modified on Monday, March 21, 2011 7:53 PM
|
|
|
|
|
The only way to get at an Access database without writing your own communication component is through a network share. You have to be able to map a drive to wherever the database sits. I'm not saying you HAVE to map a drive, you just have to be ABLE to map a drive to it. You can use the database without a drive letter if you can use a UNC path to get at it.
You do NOT have to use Access at all. If you have SQL Server, throwing Access in the middle just needlessly complicates your system.
|
|
|
|
|
Could you give a sample code for mapping drive without share the application folder?
|
|
|
|
|
You have no clue how Windows Networking works, do you? There is no code sample because you cannot map a drive to anything other than a shared folder.
|
|
|
|
|
Ok, thanks for your explanation.
|
|
|
|
|
How about if i build server component using vb 6 or microsoft access form? Could you give me a sample to do that?
modified on Wednesday, March 23, 2011 10:33 PM
|
|
|
|
|
No. I haven't touched VB6 in over 10 years.
I got my hands on VB.NET when .NET was a Beta and haven't looked back since.
If you have to make a server component just because you want to use Access, you're in deep trouble. Move to a database engine that supports this already, such as SQL Server, Oracle, MySQL, whatever... Access is probably the only database engine that doesn't support what you want to do, so why waste the effort on it?
|
|
|
|
|
|
Hi everybody,
I'm trying get my byte array into a structure successfully with the following code. Unfortunately I have no idea how to consider endianness of the data - I'd need the bytes swapped!
<StructLayout(LayoutKind.Sequential, Pack:=1)> _
Public Structure FILEHEADER
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=4)> Dim magic As String
Dim offset As UInt32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=8)> Dim version As String
Dim fileSize As UInt32
Dim dittoKey As UInt32
Dim genericSize As UInt32
Dim industrySize As UInt32
Dim userSize As UInt32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=100)> Dim fileName As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=24)> Dim timedate As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=100)> Dim creator As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=200)> Dim project As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=200)> Dim copyright As String
Dim encryptKey As UInt32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=104)> Dim Reserved As String
End Structure
Sub Main()
Dim fh As FILEHEADER = New FILEHEADER
ByteArray = GetBytesFromFile(myFile)
Dim MyGC As GCHandle = GCHandle.Alloc(ByteArray, GCHandleType.Pinned)
fh = DirectCast(Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, GetType(FILEHEADER)), FILEHEADER)
MyGC.Free()
Console.WriteLine("Magic:" & fh.magic)
Console.WriteLine("Offset:" & fh.offset)
Console.WriteLine("Version:" & fh.version)
Console.WriteLine("File Size:" & fh.fileSize)
Console.WriteLine("Ditto Key:" & fh.dittoKey)
Console.WriteLine("Generic Size:" & fh.genericSize)
Console.WriteLine("Industry Size:" & fh.industrySize)
Console.WriteLine("User Size:" & fh.userSize)
Console.WriteLine("File Name:" & fh.fileName)
Console.WriteLine("Time-Date:" & fh.timedate)
Console.WriteLine("Creator:" & fh.creator)
Console.WriteLine("Project:" & fh.project)
Console.WriteLine("Copyright:" & fh.copyright)
Console.WriteLine("Encrypt Key:" & fh.encryptKey)
Console.WriteLine("Reserved:" & fh.Reserved)
Console.WriteLine(StrDup(30, "-"))
'Console.WriteLine("actFlatAct:" & String.Concat((From s In fh.ActFlatAct Select s.ToString("f2") & " ").ToArray))
Console.WriteLine("FILEHEADER size:" & Marshal.SizeOf(fh))
Console.ReadKey()
End Sub
Does anyone have an idea how to get the bytes in the swapped endian order?
Thanks for your hints!
Mick
|
|
|
|
|
The marshaler doesn't support changing the byte order, so you'd have to do it yourself with a Custom Marshaler[^].
|
|
|
|
|
Thank you for making that clear, Dave. Would you think, considering overall performance, that the effort of custom marshalling makes sense at all then? I have a byte array in the wrong endian order, and might as well swap and assign the bytes to my structure within a loop.
|
|
|
|
|
I didn't know if you had contorl over that, but yes, that would work too.
|
|
|
|
|
Can I export to OpenOffice from DataGridView? I can export to MS Word and MS Excel.
|
|
|
|
|
There is this[^] pdf file which is in c#, if you are able to translate.
If not, I used c# openoffice interop as my search phrase, just substitute 'vb' for my 'c#' and see what you get. Bound to be something useful.
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.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
ivo75 wrote: Can I export to OpenOffice from DataGridView? I can export to MS Word and MS Excel
Yes. You can probably open the files that you're generating for Word and Excel using OpenOffice Writer and Calc.
I are Troll
|
|
|
|
|
OK but can I export to word or excel without word or excel in my PC.
|
|
|
|
|
Yes, by exporting as RTF and CSV respectively. OpenOffice knows both formats too. Exporting to CSV is most easily done using a OleDb connection.
I are Troll
|
|
|
|
|
|
No. Without Word or Office installed, you cannot export to one of the Office native formats without Office installed.
Well, maybe. If you're trying to export to Office 2003 native formats, you'd have to find a third party library that can write those formats.
For Office 2007 and above, you can go through some of this[^] since Microsoft abandoned the proprietary formats and adopted an open XML file format instead.
|
|
|
|
|
..simply say "no", as the next question is going to be why it can't read Excel-files from Office 95/97
I are Troll
|
|
|
|
|
Is proprietary. Means you'll need the software installed, just as if it were a regular application like Autocad. Or go for OpenXML
I are Troll
|
|
|
|