|
Ok I get it now.
But is there any other way of doing it?
|
|
|
|
|
Maybe, haven't tested this :
Select blabla FROM YourTable WHERE
CASE
WHEN @a = 'YourColumn1' THEN YourColumn1
WHEN @a = 'YourColumn2' THEN YourColumn2
ELSE YourColumn1
END
= @value
If this works it has the drawback is that when columns are added or changed, you need to edit your query.
Cheers
[edit] forgot the END [/edit]
I don't like my signature at all
modified on Saturday, July 3, 2010 8:51 AM
|
|
|
|
|
Very poor example that opens up sql injection attacks
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Column names are not simple strings, they are literals that represent values from the sys.columns table.
In oder to do this you need to construct the sql dynamically and I highly and strongly recommend you do it in a stored procedure
As an example:
declare @value nvarchar(255)
declare @column nvarchar(255)
set @value = 'Some value'
set @column = 'ColumnName'
declare @sql nvarchar(1024)
set @sql = 'select * from tblcustomer where ' + @column + ' = ''' + @value + ''''
exec(@sql)
Notice that @value needs to be in quotes since it is a string. Also, don't use * to return results. It is more efficient to return named columns and better documented.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hello,
I am using GCHandle to allow unmanaged code to access some managed data.
My code is as follows:
<br />
byte[] data = new byte[numBytes];<br />
GCHandle dataPtr = GCHandle.Alloc(data, GCHandleType.Pinned);<br />
Now what I would like to do is to be able to address with an offset into my dataPtr array. So, I need to get the address of an element (say element number 100) and pass that to my unmanaged C++ code. I see some method to convert it ToIntPtr(). However, does anyone know what might be the best way to address the offset?
Many thanks,
keith
|
|
|
|
|
You can use dataPtr.AddrOfPinnedObject() to get the IntPtr . You can convert an IntPtr from/to an int for any pointer arithmetic.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Did not think this post would generate so many replies!
Many thanks everyone.
Cheers,
Keith
|
|
|
|
|
I've just had a thought about my previous response, for 64bit applications any pointer arithmetic will need to be done on a long rather than an int !
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
I was going to reply that to your first post, but then I though "it has a native part, so it will probably be 32bit only anyway" and decided not to post.
|
|
|
|
|
That's a dangerous assumption that's bitten us on the ass in the past, unless you like thunking the app down to 32 bit later on.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Just because that happened, doesn't mean it's likely
Besides, OP knows how many bits he's using
|
|
|
|
|
harold aptroot wrote: Just because that happened, doesn't mean it's likely
Funnily enough, those are almost exactly the words that the client architect used when he landed us with the POS that we ended up having to fix.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
That's a nice coincidence, but it means nothing
Plus, OP knows how many bits he's using - if that was 64 and he uses int anyway it's entirely his own fault
|
|
|
|
|
Sorry harold, but on this one I have to disagree.
harold aptroot wrote: if that was 64 and he uses int anyway it's entirely his own fault
If he inherits other peoples code that does this, then it's not his fault.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
He'd be asking a different kind of question if he were
|
|
|
|
|
I was sitting watching a film with the family and it suddenly popped into my head! It's better dealt with now rather than later when his pointers turn out to be invalid and he has no clue why.
I've just knocked up a utility struct wrapping IntPtr with arithmetic/conversion operators built in for future use prompted by this to solve this problem the next time I need it. Not sure whether to post as a Tip or just as an answer to the OP...
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Why not do both? As tip + a link here?
If you'd just post it here, it would get buried in the avalanche of posts..
|
|
|
|
|
Done[^]
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Looks good, this will come in handy
|
|
|
|
|
I've just posted a small wrapper struct around IntPtr that might help!
Here it is[^].
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi Sir,
I am a reading a character typed from combobox.
But for the first time,the value is getting empty
I am trying with this code :
void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
{
string str;
str = comboBox1.Text;
MessageBox.Show(str);
}
In VC++ i used this and got the text,
void CTest1View::OnEditchangeCombo1()
{
CString strTemp;
m_ctrlCombo.GetWindowText(strTemp;);
}
Am i in the right function??
Thanks
Raj
|
|
|
|
|
You need to set the index, by default the cbo value is set to -1 that's why you getting empty string.
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Hi sir,
Thanks for your reply,
But where i have to set index,??
nnd what i have to set.??
Thanks
Raj
|
|
|
|
|
just set the cbo.selectedIndex = 1 (this will select the text of the index 1). You will decide which index you want to load / show first.
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
thank you dear..
What rule is appropriate in the Sugeno method ?
|
|
|
|