Click here to Skip to main content
15,888,984 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Conversion from string "18/8/2009" to type Date is not valid... Pin
Richard MacCutchan19-Nov-09 6:20
mveRichard MacCutchan19-Nov-09 6:20 
GeneralRe: Conversion from string "18/8/2009" to type Date is not valid... Pin
Mycroft Holmes19-Nov-09 11:41
professionalMycroft Holmes19-Nov-09 11:41 
QuestionRead sms from any gsm mobile Pin
sanjay.gujarkar18-Nov-09 18:11
sanjay.gujarkar18-Nov-09 18:11 
AnswerRe: Read sms from any gsm mobile Pin
Ashfield19-Nov-09 1:35
Ashfield19-Nov-09 1:35 
QuestionRe..............SMS Send Pin
sanjay.gujarkar18-Nov-09 18:09
sanjay.gujarkar18-Nov-09 18:09 
AnswerRe: Re..............SMS Send Pin
Ashfield19-Nov-09 1:34
Ashfield19-Nov-09 1:34 
QuestionPreventing SecurityException when deploying application using Office PIA Pin
User 1278218-Nov-09 16:50
User 1278218-Nov-09 16:50 
RantSqlParameterCollection (ADO.NET) Pin
dojohansen18-Nov-09 3:24
dojohansen18-Nov-09 3:24 
I had a command that inserted two tables, both using identity columns as primary keys. The identity value obtained from the first insert was used in inserting the second table, and two output parameters on the command should reflect the value of the two primary keys after insertion.

The command text was hence something like

INSERT A VALUES (@p1, @p2);
SET @A_ID = SCOPE_IDENTITY();

INSERT B VALUES (@p3, @p4, @A_ID);
SET @B_ID = SCOPE_IDENTITY();


I had added sql parameters for the identity values, and set the parameter direction to Output. After executing the command, I found that cmd.Parameters["@B_ID"].Value had been correctly set, but the @A_ID parameter invariably had the value zero.

Looking at the inserted data however what was really made me wonder what was going on here. The B record contained the correct foreign key, demonstrating that @A_ID had indeed been assigned correctly!

After hours of headscratching I stumbled upon the explanation: The code creating the command first added a parameter @A_ID as an input parameter, then added another parameter also named "@A_ID" as an output parameter. I don't know how exactly the provider communicates the variable declarations to SQL Server, but it appears that the second declaration simply overwrote (redeclared) the already-defined @A_ID. Then, when my code attempted to get the value, the SqlParameterCollection probably did a linear search returning the first parameter with a matching name, which of course was the input parameter.

While not checking for duplicate declarations may save a few microseconds, it would have been nice if by default such validation was performed and could be disabled instead via the ado.net configuration (for production). I certainly lost a lot of time, and probably some hair, before I found out. If it sounds like I was just being slow, let me add it wasn't that easy to check everything when the command had about 100 parameters.
GeneralRe: SqlParameterCollection (ADO.NET) Pin
Abhishek Sur18-Nov-09 9:55
professionalAbhishek Sur18-Nov-09 9:55 
QuestionBrowser - autorefresh - background render - c#.net Pin
DirkVDW17-Nov-09 23:56
DirkVDW17-Nov-09 23:56 
AnswerRe: Browser - autorefresh - background render - c#.net Pin
Simon P Stevens18-Nov-09 1:18
Simon P Stevens18-Nov-09 1:18 
GeneralRe: Browser - autorefresh - background render - c#.net Pin
DirkVDW20-Nov-09 4:17
DirkVDW20-Nov-09 4:17 
QuestionHow to emebed a html file in another html file Pin
Member 305788717-Nov-09 23:19
Member 305788717-Nov-09 23:19 
AnswerRe: How to emebed a html file in another html file Pin
Simon P Stevens18-Nov-09 1:12
Simon P Stevens18-Nov-09 1:12 
GeneralRe: How to emebed a html file in another html file Pin
The Man from U.N.C.L.E.18-Nov-09 2:52
The Man from U.N.C.L.E.18-Nov-09 2:52 
GeneralRe: How to emebed a html file in another html file Pin
Simon P Stevens18-Nov-09 4:55
Simon P Stevens18-Nov-09 4:55 
AnswerRe: How to emebed a html file in another html file Pin
Not Active18-Nov-09 2:08
mentorNot Active18-Nov-09 2:08 
QuestionExcel user defined function in C# Pin
dims1217-Nov-09 4:46
dims1217-Nov-09 4:46 
AnswerRe: Excel user defined function in C# Pin
EliottA17-Nov-09 5:28
EliottA17-Nov-09 5:28 
AnswerRe: Excel user defined function in C# Pin
The Man from U.N.C.L.E.17-Nov-09 6:42
The Man from U.N.C.L.E.17-Nov-09 6:42 
AnswerRe: Excel user defined function in C# Pin
Richard Tanios1-Dec-09 18:06
Richard Tanios1-Dec-09 18:06 
Questioncalling of dll from another dll when both are in same folder Pin
vikas shukla17-Nov-09 0:01
vikas shukla17-Nov-09 0:01 
AnswerRe: calling of dll from another dll when both are in same folder Pin
Luc Pattyn17-Nov-09 1:33
sitebuilderLuc Pattyn17-Nov-09 1:33 
AnswerRe: calling of dll from another dll when both are in same folder Pin
Shameel17-Nov-09 2:39
professionalShameel17-Nov-09 2:39 
Questionseparating the messages received in socket communication Pin
k3rkiran16-Nov-09 22:21
k3rkiran16-Nov-09 22:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.