Wednesday, August 20, 2025

How to use two displays or two monitors with one mouse

>Right click on desktop

 >Go to display settings

> and there is option of "Duplicate these videos", "Extend these videos" and click on Extend these videos , it will work for both monitors.


and use "microsoft without borders" for two different computers and having same mouse.

Friday, August 15, 2025

How to open binary file from database on browser- only display

 byte[] bytes =   file.FileData;

Response.Clear();

    Response.ContentType = file.ContentType;

Response.BinaryWrite(bytes);


https://www.aspsnippets.com/questions/206135/Open-Show-Base64-PDF-data-in-new-window-Tab-using-C-and-VBNet-in-ASPNet/

How to open new window with width and height - using window.open

  <a href="#" onclick="MyWindow=window.open('https://www.aspsnippets.com/Articles/660/Display-image-from-database-in-Image-control-without-using-Generic-Handler-in-ASPNet/','MyWindow','width=600,height=300'); ">click to open new window</a>

How to view the image in browser from database - binary image from database - asp.net

  string alert1 = "var image = new Image();";

        alert1+= "image.src='data:image/jpg;base64,"+ Convert.ToBase64String(bytes)+"';";

        alert1 += "var w = window.open('');";

              alert1+= "w.document.write(image.outerHTML);";


           ScriptManager.RegisterStartupScript(this, this.GetType(), "OpenNewTabScript", alert1, true);


ref:-https://stackoverflow.com/questions/27798126/how-to-open-the-newly-created-image-in-a-new-tab

Thursday, August 14, 2025

System.InvalidOperationException: ExecuteScalar: Connection property has not been initialized.

 This error comes when you write below code:-


using (SqlCommand cmd=new SqlCommand("SELECT TOP 1 [FileID]  FROM [UploadFiles] order by Fileid desc"))


and not passed con as second parameter in SqlCommand. Use below code

using (SqlCommand cmd=new SqlCommand("SELECT TOP 1 [FileID]  FROM [UploadFiles] order by Fileid desc", con))


also you have to add below line

cmd.CommandType = System.Data.CommandType.Text;