Friday, June 26, 2020

Enable sa Login in sql server

sa user disabled or sa login failed or enable sa login or sa login enable

1.  Go to window login > right click > properties > enable window and sql server authentication
then ok



Thursday, June 11, 2020

Partial spacific property update in ef or single property or one property or spacific



[HttpPost]
public async Task<ActionResult> update_nominee(custreg_working d, string id)
{

    using (var context = new db_context())
    {
        d.cust_id = id;
        context.Configuration.ValidateOnSaveEnabled = false;
        context.custreg_working.Attach(d);
        System.Data.Entity.Infrastructure.DbEntityEntry<custreg_working> entry = context.Entry(d);

        entry.Property(e => e.Nominee).IsModified = true;
        entry.Property(e => e.Relation).IsModified = true;
        entry.Property(e => e.nmob).IsModified = true;

        await context.SaveChangesAsync();
    }
    return RedirectToAction("edit", new { id = d.cust_id });
}

Monday, June 8, 2020

sql recursion or recursion in sql server or go to



DECLARE @text VARCHAR(50) = NULL;
nn:
if(@text is not null)
begin
EXEC [dbo].[CreateRandomString] @minLength = 10,@maxLength = 10, @randomString = @text OUTPUT;
end
if(@text is null) begin
set @text='Pudzw6p5w'
end
if(select count(*) from product_keypin where pinkey=@text)>0
begin
print 'Duplicate'
goto nn
end else begin
print 'No Duplicate'
end;

Linq Expression syntax for where condtion in linq

(Expression<Func<T, bool>> filter)