Sql command parameters

jay8anks

Active member
Joined
May 6, 2022
Messages
31
Programming Experience
5-10
Stupid question, but I have never been able to find an answer to this. When I first started doing Asp.Net in C# or VB, all the examples to add SQL command parameters look like:

cmd.Parameters.AddWithValue("@Id", rowId);

When going back through my code, I sometimes find I did this: cmd.Parameters.AddWithValue("Id", rowId);

It works just fine. Also, after using Dapper a little lately, a lot of the examples don't add the ampersand, either.

What exactly does the ampersand do with SQL parameters? Is it a .net thing or does it do something in the sql server.

This is yet another one of those things that is hard to search for, because it pulls up all kinds of things except what I'm wondering here.

Thanks,
 
Oh, I've no idea what's going on then, because this is what I see (on an iPhone) on line 877:

5AEA4886-3620-4158-BFE4-259EDFDEAFAA.jpeg


Your line 545..!?

Interesting trick with the yoda; my learning day moment today :)
 
Last edited:
Just had a closer look and it looks like on an iPhone the line numbers don't actually line up with the code..

1C78504F-2527-423C-866D-E9A7AE6B9063.jpeg


It's out by around 50% - 30 line numbers for 20 lines of code! Bit of a fail there MS.. I wonder if they're relying on font height equivalence to keep things in step

Note to self not to use line numbers on that site any more! GitHub's fine..
 
I wonder if they're relying on font height equivalence to keep things in step

Note to self not to use line numbers on that site any more! GitHub's fine..
It appears so. I just took a look at the page source and they are using a table with only one row, where the entire list of line numbers is one cell and the entire code listing is another cell. They are both wrapped in <pre> tags and both have a font-size of 12pt from that. It's a bit of a dodgy way to do things these days but it should still work, so I'm not sure what Safari is doing there.
 
Back
Top Bottom