|
Me.DataGridView1.DataSource = dataset11.tables(0)
should work for you
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
That looks good to me! (no pun intended).
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
I have some code within try...catch blocks that might not always execute properly. One error that might occur is a System.InvalidCastException error. I trap the error, but can I prevent the error from being written to the log?
Thanks
|
|
|
|
|
And who is writing those exceptions to the log? remove the code that does that. Or, much better, do what it takes not to have those casting exceptions in the first place (can't provide detailed help witout seeing the offensive code).
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.
|
|
|
|
|
Catch the specific Exceptions first, then the generic Exception:
Try
'some code
Catch System.InvalidCastException
'do something
Catch Exception
'log it and do something
End Try
But of course you should better find the reason for those InvalidCastException, and get rid of them.
|
|
|
|
|
Ok so here is my issue.
In all the years that I've been coding I have never come accross this issue or error. For the past 3 months I have been working on two separate apps. Initialy I started out with Win Vista and things were going great except for how slow my comp was running. So I reinstalled the Vista OS. Everything was going great until Mar 7th when this error just started occuring within my code.
"Access to the registry key 'HKEY_CURRENT_USER\Software\TornadoApps\Swift Budget\User' is denied"
"TornadoApps/Swift" Budget are strings created upon App install or first run of App in VB 2008.
The "Use"r value along with 9 other values were all working fine prior to Mar 7th.
Now this line along with many others like it with defferent strings and values were working just fine till this week. So i figured that I'd just upgrade to Win7 hoping that would fix it. IT didn't. So I reformatted and installed fresh Win7 and still have the error. So I have figured out that it isn't my OS. Cuase it was working in Vista then just quit working.
Can anyone help me.
|
|
|
|
|
Sometimes you have to manually set these things.
Obviously I cannot tell you the settings for this particular app, but you will need admin rights.
Perhaps re-installing the app may help too, but remove the regentry before reinstalling.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Here's the thing.
On Mon both apps, of my design, were working fine.
Both written in Visual Basic 2008.
One I've been working on since Dec the other just started.
Both access the same reg key, "TornadoApps" and sub keys of "Swift Budget" and "ABO".
Both were working on monday and then for no reason jus stopped workin.
Even after I reformated my comp this error still occures.
|
|
|
|
|
Are you using a network login? If so has the network admin down graded the user id so it is no longer a full admin?
A long shot, but have seen something like this in the past (early days of switching to XP).
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
Hello,
u can solve this problem by disabling "User control settings"
Go to: Control Panel\User Accounts and Family Safety\User Accounts\User control settings
then choose: "Never notify"
|
|
|
|
|
hey ppl,can ny1 suggest me hw to go bout the following.
I'm creating a simple application which includes 3 forms,which takes i/p,stores in the database(i'm using sql server 2008) and display back the searched item,now my problem is tat i want to create a setup file for the above application,in which my application should do the following..
->it shud include the database wich im usin in sql server 2008 in the setup file
->the setup shud successfully be installed on ny othr machine wich doesn't hav the sql server
thanks in advance..
|
|
|
|
|
Free Advice.
Do not use txtspk here.
It is universally loathed, you will not get helped and it makes you look like a child or stupid.
I am sure you are not stupid, so edit you question to reflect this.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Hi Guys
I'm trying to develop a program that is similar to windows explorer. The look and feel of the program is pretty much done.
There is a tree view pane and a list view pane, the tree view pane looks to a local folder (folder2) and displays all folders in that directory. The list view pane shows all files in the corresponding node of the tree view.
The next step is to make the local directory (folder2) pull updated files from a server folder (folder1) as and when there is an updated file put onto the server.
So if a new folder is put on the server in a sub directory for example the program must only copy the updated file over to the local directory.
Here are the basic parameters needed:
1.)I would like this process to happen continuously
2.)It would probably be best to check for an updated file based on date and time modified
3.)I only want the synchronization to happen fron the server to the local pc
I have been told that the microsoft sync framework will be able to do this, but to find a tutorial for VB is like looking for a needle in a haystack.
Please keepin mind that i am seriously new to VB and coding in general!
Is there anything else that i could do to make it clearer or help you guys help me
Thanks in advance
|
|
|
|
|
Here is a Good Article using the FileSystemWatcher. It is in C# but you could use a csharp-to-vb converter.
Hope that helps
"You get that on the big jobs."
|
|
|
|
|
Thanks man
I'll take a look...
But is there anybody out there that can point me to a simpler snippet of code, perhaps using a better structure like the sync framework?
modified on Friday, March 11, 2011 7:44 AM
|
|
|
|
|
Iam using VS2008. Iam developing a application, it contains few forms... But few Forms need certain same calculation, so I can have a Sub or Function...and can call to my required forms....But where to have those Functions...?..
I mean whether we can have a New Form or Class or Interface or Resource File or ..????
Thanks For The Ideas....
|
|
|
|
|
Surely just making them public would help?
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Thanks Dave...I get clear...
|
|
|
|
|
making them public in a module would solve it
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
Create a public class and add the Subs/Functions for those calculations as Shared:
Public Class App
Public Shared Sub WhatEverItDoes()
End sub
End Class
And call these Subs/Functions as needed:
App.WhatEverItDoes
|
|
|
|
|
Creating a module which contains this common functionality is one way (as previously mentioned)
Creating a form which contains this common functionality and inheriting from this form instead of Form is another.
Creating a shared method within a particular form (as previously mentioned), is another but one I don't like.
"You get that on the big jobs."
|
|
|
|
|
If they are static functions, then create a new Module (Project > Add Module...) and place them in there as Public Shared (Sub|Function) .
-Greg
|
|
|
|
|
Hi,
I'am updating and old VB6 project to VB.net 2008.
My old project uses a Win32 Dll and TLB file to shared types.
From VB6 a reference is created to TLB file and interop works fine.
From VB.net I can import TLB file successfully and types are accessibles, but not the functions.
Using 'Declare Function' sentences to import DLL methods, I can access to DLL functions.
My Win32 DLL has methods that uses LPSAFEARRAY pointer as input parameters.
This is the declaration of one of this functions on DLL:
extern NOMANGLE short CCONV EncenderLEDs(LPSAFEARRAY *CBLeds, bool Estado);
To reference this from VB.net I write
Public Declare Function EncenderLEDs Lib "MonAuto.dll" (<MarshalAs(UnmanagedType.SafeArray)> ByRef CBLeds() As CBTipo, ByVal Estado As Boolean) As Integer
CBTIPO is defined on DLL as:
typedef struct{
short Carta;
short Borna;
} CBTipo;
The type is correctly visible at VB.net after TLB is imported.
I test the function with next code:
Dim CBLeds() as CBTipo
Redim CBLeds(4)
CBLeds(0).Borna = 0
CBLeds(0).Carta = 0
EncenderLEDs(CBLeds, False)
An exception is reported:
(Exception of HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND))
But if I use any single Type to create the array: Int32, Double, Single, byte, ... and modify the declaration function definition on Vb.net like:
Public Declare Function EncenderLEDs Lib "MonAuto.dll" (<MarshalAs(UnmanagedType.SafeArray)> ByRef CBLeds() As Integer, ByVal Estado As Boolean) As Integer
and modify the test in the same way:
<pre>Dim CBLeds() as Integer
Redim CBLeds(4)
CBLeds(0).Borna = 0
CBLeds(0).Carta = 0
EncenderLEDs(CBLeds, False)</pre>
Then the call is processed good.
The question is, How must be defined a DLL Win32 function on VB.net that uses a LPSAFEARRAY * as input parameter, to send a userdefined type array ?
I've tried:
Public Declare Function EncenderLEDs Lib "MonAuto.dll" (<MarshalAs(UnmanagedType.SafeArray, SafeArraySubType:=VarEnum.VT_USERDEFINED)> ByRef CBLeds() As CBTipo, ByVal Estado As Boolean) As Integer
and fails too.
Regards in advance
|
|
|
|
|
Very beautiful question.
LPSAFEARRAY is a pointer itself, so LPSAFEARRAY* is a pointer to pointer declaration. This is what I would try:
Public Declare Function EncenderLEDs Lib "MonAuto.dll" (cbLeds() As IntPtr, estado As Boolean) As Integer)
Your first array initialization is ok, but in order to pass it to that function, you should first pin the objects in the managed heap, create the IntPtr array with their addresses and pass this array. This is very similar to another question I answered in C# forum[^] some time ago, so let me bring it to you with some of the required changes. It is still C#. I will not convert it to VB becouse I do not feel comfortable enough with this language, and I could end up with a little mess.
GCHandle[] handleArray = new GCHandle[cbLeds.Length];
for (int i=0; i<cbLeds.Length; i++)
handleArray[i] = GCHandle.Alloc(cbLeds[i], GCHandleType.Pinned);
IntPtr[] pointers = (from GCHandle handle in handleArray select
handle.GetAddrOfPinnedObject()).ToArray();
int ret = EncenderLEDs(pointers, false)
foreach (GCHandle handle in handleArray)
handle.Free();
Please, let us know if it worked.
|
|
|
|
|
No good result.
The translated code to VB is:
Dim CBLeds(4) As CBTipo
CBLeds(0).Borna = 0
CBLeds(0).Carta = 0
Dim handleArray(4) As GCHandle
For i As Integer = 0 To CBLeds.Length - 1
handleArray(i) = GCHandle.Alloc(CBLeds(i), GCHandleType.Pinned)
Next i
Dim pointers() As IntPtr = (From handle As GCHandle In handleArray Select handle.AddrOfPinnedObject()).ToArray()
Dim ret As Integer = EncenderLEDs(pointers, False) ' Release the handlesforeach (GCHandle handle in handleArray) handle.Free();
For Each handle As GCHandle In handleArray
handle.Free()
Next
When I Call the DLL function, the process operates normally (no exception appears) but DLL function not executes correctly.
Below you can see the code at EncenderLeds function.
I'm getting the Ubound and Lbound of array to verify that this is passed good.
The return of SafeArrayGetLBound is DISP_E_BADINDEX 8002000B
The return of SafeArrayGetUBound is DISP_E_BADINDEX 8002000B
So execution is failed.
NOMANGLE short CCONV EncenderLEDs(LPSAFEARRAY *CBLeds, bool Estado)
{
CBTipo HUGEP *Leds;
long LBound, UBound;
DWORD BytesWritten;
DATA Adat[256];
short ActAdat=0;
short nLed;
int j;
USHORT ErrorCnt;
char Cadena[200];
for(unsigned char i=0;i<128;++i)
{
Adat[i].Address = 0;
Adat[i].Data = 0;
Adat[128+i].Address = 0;
Adat[128+i].Data = 0;
}
int k,l;
k=SafeArrayGetLBound(*CBLeds,1,&LBound);
l=SafeArrayGetUBound(*CBLeds,1,&UBound);
sprintf(Cadena,"Valores %x %x %d %d",k,l,LBound,UBound);
MessageBox(NULL,Cadena,"Titol",0);
return 0;
}
Any Idea what is happen?
|
|
|
|