|
Thanks
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
ez2 wrote:
if(e.KeyCode == Keys.Right)
Sorry,It doesn't exist in System.Windows.Forms.KeyPressEventArgs ,So How can I use it?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
mazdak,
I just checked and your right. It looks as though keyPressEventArgs only handles characters (i.e. e.KeyChar returns a char) and not other keys like ALT, Arrows, etc. Not sure why that is so I will do some checking.
Alternatively, you could use the Keydown event which does have a KeyEventArgs and you can trap additional keys. In that case,
if(e.KeyCode == Keys.Right) should work.
I need some clarification myself on keydown vs. keypress anyway so I will let you know what I find.
|
|
|
|
|
jap - thats the way it goes.
keypressed is somewhat focussing on characters (in fact, the type of the KeyChar-property is char)
special keys (like arrows/functionkeys/etc.) you can only handle using keyup/keydown (the KeyCode-property in there is of the Keys type)
:wq
|
|
|
|
|
I try to connect to a password secured database, with oledbdataadapter
and I use the following connection string :
@"Provider=Microsoft.Jet.OLEDB.4.0;User ID = admin;Password=""123"";Data Source=F:\Mehdi\C#\Source Code\Filing System Manager\Sample.mdb;"
then I get the following error :
---------------------------
Microsoft Data Link Error
---------------------------
Test connection failed because of an error in initializing provider. Cannot start your application. The workgroup information file is missing or opened exclusively by another user.
---------------------------
OK
---------------------------
I would really apreciate an advise on this case
thanks
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
I was receiving the same error when I was looking at this for you the first time.
I came up with the following solution (As stated in MSDN).
Change the following registry key to point to your .mdw security file.
\HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\Engines\SystemDB
I thought it was a bit of a hack, but I found enough documentation (in MSDN) that kept repeating it, so I tried it, and it works...
There has to be a better way...
Regards
|
|
|
|
|
Just found the better way...
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;User ID=Peon;Password=PeonPassword;Data Source=C:\MyPath\SomeDatabase.mdb;Jet OLEDB:System database=C:\MyPath\MySecurityDatabase.mdw";
Regards
|
|
|
|
|
Thank you Neil,Now I'm not at place to check it but I'll do it as soos as possible.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Hi neil,
Thanks for the help, it solved my problem.. well almost !!!
Now I get this error message (It's because of the username and password of the mdb file, ichecked it )
with the right username and password it gives the same thing !
---------------------------
---------------------------
Index #0
Message: Not a valid account name or password.
Native: -124585838
Source: Microsoft JET Database Engine
SQL: 3029
---------------------------
OK
---------------------------
It's really getting on my nerves
I wonder if u could solve this problem, too.
thanks
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
My passwords work , Sorry...
I did notice your connection string had quotes (in the root of this thread) around the password, get rid of those...
Regards
|
|
|
|
|
I put a WAVE file into the resource as a Embedded resource. How to play it now? Could someone give me an example?
|
|
|
|
|
Since there isn't any managed methods for playing sounds you'll have to load the file from the stream into memory, then call the appropriate API function to do the actual playing.
To get the stream this should work.
public byte[] GetWave(string filename)
{
Assembly asm = GetType().Assembly;
Stream stream = asm.GetManifestResourceStream(filename);
byte [] wav = new byte[stream.Length];
stream.Read(wav, 0, wav.Length);
return wav;
} Untested but it should work since I wrote almsot the exact same code in another program.
I'm not familiar with the sound playing API though so you'll have to reference that on your own.
James
Simplicity Rules!
|
|
|
|
|
Thanks, but does anyone knows how to open these wave bytes??? I know that there's an API function called PlaySound, but it can play from file or from *Win32* resource. As far as I'm concerned C# doesn't compile resources as a Win32 type, but as it own format... Any ideas?
|
|
|
|
|
This is one of those areas where I can't help but think *there has to be a better way*...
If you take Mr. Johnson's GetWave method above and combine it with something like this...
public static void PlaySoundMemory(string resid)
{
PlaySound(
IntPtr.Zero,
IntPtr.Zero,
PlaySoundFlags.SND_SYNC
);
byte[] buffer = GetWave(resid);
if (null != buffer)
{
IntPtr p = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0);
PlaySound(
p,
IntPtr.Zero,
PlaySoundFlags.SND_SYNC | PlaySoundFlags.SND_MEMORY
);
}
}
You end up with something that works. You could also write the resource to a temp file and play it directly from there. The PlaySound Function and the PlaySoundFlags are just API definitions lifted from the Platform SDK headers.
Regards
|
|
|
|
|
Yesss, now it works!!! Thanks a lot!!!
|
|
|
|
|
Does anyone know how I can launch a URL in C# ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
System.Diagnostics.Process myproc = new System.Diagnostics.Process();
myproc.Start("IExplore.exe", "http://www.microsoft.com");
Why in the world Process is part of the Diagnostics namespace is beyond me though :-P
James
Simplicity Rules!
|
|
|
|
|
bah, I just realized this only works for IE and not the default browser
However, what happens if you put the URL inplace of IExplore.exe?
James
*James is currently munching on some pizza so he can't be bothered to type a test program in with one hand *
Simplicity Rules!
|
|
|
|
|
Just setting the .StartInfo.FileName property to the URL and the StartInfo.Verb to "Open" should do the trick...
i.e.
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "http://www.codeproject.com/";
process.StartInfo.Verb = "Open";
process.Start();
Regards
|
|
|
|
|
I found that start was a static method, I had to do it all in one line. Is this not the case ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
The Start method I use in the given code (no parameters) is not static. The others are.
Regards
|
|
|
|
|
Doh, blame the documentation :-P
What I wrote was a conversion of a VB sample
James
Simplicity Rules!
|
|
|
|
|
Thanks - between you and Neil I think I have all I need to update the code tonight for the 7 people still using Netscape, although they are all more likely to be using a slashdot screensaver than one from CP
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
Christian Graus wrote:
be using a slashdot screensaver
I think they're running SETI
James
Simplicity Rules!
|
|
|
|
|
I'm a newbie when it comes to C# and I was wondering if someone can help me with it. Has anyone successfully use the ListView.Items.Contains method? It does not work for me at all (always returns a "true" no matter what the data).
here's an example code of what I did:
//----------------------------------------------
string FilePath = @"C:\SomeFolder\SomeFile.txt";
FileInfo FI = new FileInfo(FilePath);
string[] fileInfo = {FI.Name,FI.DirectoryName};
ListViewItem myListItem = new ListViewItem(fileInfo,0);
if(lvMain.Items.Contains(myListItem) == false && tFI.Attributes != FileAttributes.Directory)
{
listView1.Items.Add(myListItem);
}
//----------------------------------------------
It works fine the first run, but if I run the code again with the same FilePath info it still adds the myListItem onto the listView1, resulting in redundant entry in my ListView control...
please someone help me get this Contains method to work! TIA
|
|
|
|