Posts

Showing posts from July, 2019

Microsoft Access Connectivity from C#

<configuration>   <appSettings> <add key= "ConnectionString" value= "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=BCI.accdb;" /> <add key= "ClientSettingsProvider.ServiceUri" value= "" />   </appSettings> </configuration>

Image file upload in a selected folder in C#

protected void LinkButton1_Click(object sender, EventArgs e) {     string filePath = "" ;     if (fileUpload.HasFile)     {         if (CheckFileType())         {             string postedLogo = fileUpload.PostedFile.FileName.ToString();             string fileName = postedLogo.Split( new char [] { '\\' }).Last();             string fileExtension = fileUpload.PostedFile.FileName.Split( new char [] { '.' }).Last().ToLower();             filePath = "~/MemberPhoto/" + fileUpload.FileName.Replace(fileName, Session[ "UserId" ].ToString() + "." + fileExtension);             try             {                 System.Drawing.Image UploadedImage = System.Drawing.Image.FromStr...

Read from excel and insert into data table in c#

using System.Data.OleDb; using System.IO;   private DataTable ReadExcelToTable ( string path ) {         //Connection String         string extenstion = Path.GetExtension(path);         string connstring = "" ;         if (extenstion == "xls" || extenstion == "XLS" )         {             connstring = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1';" ;         }         else         {             connstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1';" ;         }         //connstring = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=NO...