Skip to main content

Posts

Reading Mixed datatypes from an Excel file with C# or asp.net

In a previous article describing how to read the data from Excel file with help of C#, the end developer may face a problem of not able to read the data from a column that contains mixed data types. For e.g. if you have got a column in which the data looks like this: 125200 568585 F25363 152525 The above data will be read except for a value starting with F . This is because when we read the excel with Oledb driver , there is a " RowsToGuess " property in the registry setting which tells how many rows to scan to govern the datatype of the column. If we set that to 0, all the rows are scanned to determine the datatype. Also we need to use IMEX  attribute setting in the connection string so that the data is always read in the "Text" Format. This will help in removing the problem. The following code shows how to set the IMEX setting: OleDbConnection vConn = new OleDbConnection("...

How to Display Images in the PictureBox used in Windows Apps or Mobile Based Apps.

Normally in windows based application there is a requirement to display image in the picture box which has been read from SQL Server. The image is stored in binary format in SQL Server. So we have to convert raw format read from database into bytes and then use stream to load the bytes in the format of an image. The following code shows how to display the image in the picture box in VB.NET    Dim vbyte() As Byte = CType(myDatarow("Snap"), Byte())    Using ms As New IO.MemoryStream(vbyte)    PictureBox1.Image = New Bitmap(ms)    PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage    End Using In the above code, myDatarow is the object of DataRow class that is read and “Snap” is the name of the column in the database that stores the image. 1. So firstly we convert the read image from SQL Server into Bytes array. 2. Then we use MemoryStream to read the bytes into the stream and load the same bytes in the format of image in t...

Display Images from SQL Server in ASP.NET Page with Generic Handler

In order to display an image stored in SQL Server on the Web Form, we need the concept of Generic Handler in ASP.NET. A Generic Handler is just any other web form that is added in the current form. A generic handler is responsible for fulfilling requests from a browser. A handler is a class that implements IHttpHandler interface. Normally the generic handler is having an extension of “Handler.ashx”. In my previous post, I discussed about the storing of an image in SQL Server which the user selects on the web page (.aspx) page. I will be continuing from the same process. The following interface is used: In the above screen shot, a textbox is there in which the Image id will be entered by the user which the user wants to display. Also the button will be used to show the same. And lastly an image control that will display the image fetched from the database. On the Show Image button the following coding is to be done. The hander is invoked with the help of following code: Protec...

Storing Images in SQL Server Image Datatype in ASP.NET

How to Store Images in SQL Server from an ASP.NET Page Normally there is a requirement in the dynamic web sites where the user uploads an image for a specific purpose like profile, product image etc. and it has to be saved in the database. This article discusses the step by step process of storing the image chosen in the ASP.NET Page into SQL Server Database. For this I have taken a small table called as “MyPhoto” which contains two fields having following details: 1. PhotoID                 Numeric                     Identity Column 2. Photo                     Image The image will be stored in the Photo Field which is of type Image and later on can be retrieved with the help of some another process ...

LPU's Infrastructure (IT)

As requested by number of students, I am posting some details about LPU's IT infrastructure (More of hardware and network components). LPU Infrastructure PDF Hope this gives details about LPU's IT infrastructure!!!!

Visual Studio .NET 2010 and .NET Framework 4 RTW.

Finally Microsoft released the RTW versions of the VS 2010 one of the most used tool in the world. It comes with .NET Framework 4 and has lot of new features to offer. Visual Studio.NET 2010 is now offered in 4 different versions: 1. Professional 2. Premium 3. Ultimate 4. Test Edition The best thing about Visual Studio 2010 is that it is itself written in WPF and offers variety new features like: Windows 7 Phone Development (really awesome) Silverlight now integrated directly as a toolbar. WCF Development RIA development jQuery out of the box support And much much more.... Soon I will be reviewing the tool.

LINQ: Language Intergated Query System.

LINQ is the new way of accesing the databases in .NET. Through this method the programmer can use the conventional syntax of querying objects in a dataset and formulate queries like they are framed in the RDBMS. The future of the database access through front end is going a sea change with the introduction of technologies like: LINQ. Will be talking about LINQ in the coming posts. Keep tuned.