I'm working...hmm...thought I'd mention a very odd bug I came across yesterday at work - which had me puzzled for about a day and a half...
I had written an application (the Portal I've mentioned before - The Education Community), which uses the Data Access Application Blockto provide the DAL - which I highly recommend. Anyway, this has always been faultless on every platform I've tried it on. The code is below...
string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
string exceptionStr=exception.ToString() + exception.StackTrace;
SqlParameter[] sqlParams = new SqlParameter[4]; SqlParameter
prmUser = new SqlParameter("@user",SqlDbType.VarChar,500);
prmUser.Value = user;
SqlParameter prmMessage = new SqlParameter("@exceptionMessage",
SqlDbType.VarChar, 2000);
prmMessage.Value = exception.Message;
SqlParameter prmExStr = new SqlParameter("@exception",SqlDbType.Text);
prmExStr.Value = exceptionStr;
SqlParameter prmPortalId = new SqlParameter("@portalId",SqlDbType.SmallInt);
prmPortalId.Value = 0; sqlParams[0] = prmUser;
sqlParams[1] = prmMessage;
sqlParams[2] = prmExStr;
sqlParams[3] = prmPortalId;
/*SqlHelperParameterCache.GetSpParameterSet(_connectionString,"pr_Admin_InsertError"); sqlParams[0].Value
= user; sqlParams[1].Value = exception.Message; sqlParams[2].Value
= exceptionStr; //sqlParams[2].Value = "Test String"; sqlParams[3].Value
= ((PortalSettings)HttpContext.Current.Items["PortalSettings"]).PortalId;*/
SqlHelper.ExecuteNonQuery(_connectionString,CommandType.StoredProcedure,"pr_Admin_InsertError",sqlParams);
I use a method it provides called SqlHelperParameterCache.GetSpParameters (commented out in the code above) - this basically just populates an array of SqlParameters with the parameters returned from the DB - saves a bit of coding and makes the app easier to update as the SPs change - nice!
Anyway, this has worked faultlessly, fast, efficient all of that! Until that is, I tried to deploy to our test environment on Thursday - I kept getting various errors, Severe Error and General Network error back from SQL Server 2000 when I tried to run the commented code above. Well, the version of .NET on that machine was 1.0.3705.352
Umm...wrong, turns out this version has a major issue when you try to get the parameters back from an SP when the SP expects a 'text' type field - it just gets it wrong somehow
Anyway, fixed now - but I do recommend you upgrade to 1.1 - which also has a fantastic thing I discovered from some blokes blog at the ASP.NET weblogs simple but saves a bit of typing, seems that DropDownList (I expect RadioButtonList has it too, but not tried it!) that is a SelectedValue property - how cool is that - well not that cool, but its' better than doing the old ddl.SelectedItem.Value...bit shorter...
© 2025 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.