|
Some have given you the answer but not really shown you what they mean. You can't use WHERE without a SELECT. So, you do something like this:
INSERT INTO Table1(Field1, Field2, ...)
SELECT '2021', 'Alex', ...
WHERE NOT EXISTS (...)
|
|
|
|
|
DevParty wrote: You can't use WHERE without a SELECT.
Um ... you sure?
UPDATE MyTable SET MyColumn = @MyValue WHERE MyOtherColumn = @MyOtherValue
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: DevParty wrote: You can't use WHERE without a SELECT.
Um ... you sure?
UPDATE MyTable SET MyColumn = @MyValue WHERE MyOtherColumn = @MyOtherValue
I'm pretty sure he meant an INSERT, clause, not an UPDATE one! 
|
|
|
|
|
What he may have meant and what he said are not necessarily the same thing!
Particularly with beginners, you have to be accurate - a bald statement like "WHERE only works with SELECT" is not accurate and can confuse.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: a bald statement like "WHERE only works with SELECT" is not accurate and can confuse.
Would that be a statement without any hair?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Wouldn't know - I still have a ponytail.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
For inserting data. Stay in context. 
|
|
|
|
|
I want to create shared memory in a C# windows application. And a second console application in visual studio has to share the same memory using OpenFileMapping function.
Is it possible to share memory as I mentioned between one application in C# and other application in Visual C++ console application.
Please advise and suggest the ways of doing this
|
|
|
|
|
The BCL has plenty of support for memory-mapped files:
Memory-Mapped Files | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This gives details for creating and opening shared memory between 2 C# application processes.
Please help me to share memory between 2 applications, one in C# and other VC++ console application to open the share memory created in C# application. Is it possible of doing this? Please advise
|
|
|
|
|
The documentation tells you how to create or access memory-mapped files from a C# application.
You presumably already know how to create or access memory-mapped files from a C++ application. If not, the Microsoft docs site has details:
Memory-Mapped File Information - Win32 apps | Microsoft Docs[^]
The file doesn't care which language was used to create the process that's accessing it.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I would strongly suggest that you don't: instead redesign to use message based communications via Named Pipes[^] or Sockets C#[^] / Sockets C++[^]
It's a much more robust solution that can be a whole load more flexible.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Going in circles.
Shared memory - C# Discussion Boards
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
But I didnt get a solution.
Please provide me some details and hints how to share memory between C# application and VC++ console application
|
|
|
|
|
You're stuck on one approach and not open to suggestions.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
If helps.
A memory mapped file is an OS supported option.
C++ can use and access a memory mapped file.
C# can use and access a memory mapped file.
So the solution is
1. Study memory mapped files so you specifically understand how they can be shared between applications. I believe sharing requires a specific set up.
2. Study the api for C++ memory mapped files.
3. Study the api for C# memory mapped files.
4. Design how the memory mapped file will be used. Pay attention to failure scenarios.
5. Use 2 and 4 to implement a solution in the C++ app.
6. Use 3 and 4 to implement a solution in the C# app.
|
|
|
|
|
Hi,
I searched DevExpress forum. They say that I need to use gridView.GetRowCellValue() method.
I used this code:
private void gridView4_DoubleClick(object sender, EventArgs e)
{
DXMouseEventArgs mouseEvent = e as DXMouseEventArgs;
GridView view = sender as GridView;
GridHitInfo info = view.CalcHitInfo(mouseEvent.Location);
if (info.InRow || info.InRowCell)
{
MessageBox.Show(gridView4.GetRowCellValue(info.RowHandle, "File Name").ToString());
}
}
But I have error in MessageBox.... line.
it says:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
DevExpress.XtraGrid.Views.Base.ColumnView.GetRowCellValue(...) returned null.
|
|
|
|
|
Either your RowHandle or column name is invalid. Use the debugger to find out which, and why.
|
|
|
|
|
|
Not too difficult was it?
|
|
|
|
|
Come on Alex!
You've been here long enough to know that the first thing you reach for with an exception is the debugger!
If fact, why are you testing your code outside the debugger anyway?
Use the debugger and it'll tell you what is null. When you know that, you can backtrack through your code to find out what should have put a value in there, and why it didn't.
Asking us to work it out is a fruitless exercise for all concerned: we have no access to your running code (which you need for run time errors) or your data (which you probably need for grid based control errors).
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hello,
i have an .exe file which is needed to be started initially as SYSTEM user.
This .exe is calling another instance(copy) of itself, but in user context so that interactive actions can be done (in this case showing a Toast Notification).
In Visual Studio 2017 i used StartAsCurrentUser.exe (GitHub - clreinki/StartAsCurrentUser: A simple EXE to utilize the functionality found in https://github.com/murrayju/CreateProcessAsUser to launch another EXE as currently logged in user[^]. And it worked well. Both processes had access to Registry/HKLM.
Now i had to switch to Visual Studio 2019, and it does not work anymore.
If the second process (in interactive mode, startet by StartAsCurrentUser.exe) tries to write a key in the Registry (HKLM), i get the error "Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\RSMGMT\Apps\TestSystemUser' is denied.
Do you have an idea how the first instance of my program can start itself as a second instance from SYSTEM context in user/interactive mode without loosing access to Registry/HKLM ?
Maybe there is an alternative to Registry/HKLM? I just want to share data between the system process and user/interactive process, both need to have read/write access to a common data basis.
I'm new to C#, so i have no idea about alternatives.
Thank you very much!
Best regards
Emanuel
|
|
|
|
|
AFAIK, to write to HKLM one has to have Admin rights.
|
|
|
|
|
The version of Visual Studio being used has nothing to do with this at all. It's just a heavy-weight editor and debugger.
Normal users do not have the ability to write to anywhere in HKLM by default. In order to open that up (NOT RECOMMENDED!!) you have to change the permissions on the keys you want your users to write to to give them (and therefore the code they launch) that ability.
A better option would be to write data to a file in a folder under %ALLUSERSPROFILE%.
|
|
|
|
|
Thank you!
I decided to solve it with an ini File.
A bit old school but it works fine.
|
|
|
|