piątek, 30 maja 2008

System.Data.SqlClient.SqlException: Login failed for user 'MachineName\ASPNET'

Maj się kończy, a wpisów na blogu niezbyt wiele :-)

Dziś tylko informacja o problemie, na który napotyka się co jakiś czas, mianowicie:

System.Data.SqlClient.SqlException: Login failed for user 'MachineName\ASPNET'


Znalazłem rozwiązanie, aczkolwiek nie do końca bezpieczne:

sp_addrolemember 'db_owner', 'MachineName\ASPNET'

Jednak dla maszyny developerskiej nie powinno być problemu.

poniedziałek, 5 maja 2008

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

No i stało się:

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack


skąd to? Po poszukiwaniach, kombinacjach, znalazłem:
re: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
by shakeel khan December 10, 2006 @ 4:59 pm

Hi,
I am getting same problem with "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack."
And always occurs even if there is no error
I used finally block and initialize bool variable in catch block and used in finally block.
Have a look code

try
{
Response.Redirect(Request.Path + "?result=submitted");

// if you using Response.Redirect or Server.Transfer in Try block you will get these error
"Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack." It’s .Net bugs.

}

catch
{
this._response = false;
// Response.Redirect(Request.Path + "?result=error");
}
finally
{
if(_response)
Response.Redirect(Request.Path + "?result=submitted");
else
Response.Redirect(Request.Path + "?result=error");
}
Eh :-) I wiecie co jest najgorsze? Że faktycznie przeniesienie redirect-a poza try..catch pomogło.

sobota, 3 maja 2008

Linq + gridview + problemy.

Na stronie Scott-a http://tiny.pl/ncj9 widnieje fajny przykład, w którym przy pomocy Eval Scott uzyskuje dostęp do obiektów połączonych ze sobą poprzez klucze obce. Np:

<%#Eval("Country.Name")%>

Problem jest taki, że czasem to nie działa. Dochodzenie wskazało na EnableUpdate="True". Dlaczego? Nie mam pojęcia, po dodaniu (do LinqDataSource) wszystko pyka jak powinno.

piątek, 2 maja 2008

Ciekawy kawałek kodu - FindControl

Przed chwilą uratował mi trochę czasu :) [Był problem z findcontrol dla masterpage-sa, gdy kontrolki były ukryte wewnątrz wizard-a.]


private Control FindControl(Control parent, string id)

{

if (parent.ID == id)

{ return parent; }

foreach (Control child in parent.Controls)

{

Control recurse = FindControl(child, id);

if (recurse != null)

{ return recurse; }

}

return null;

}