Posts

How to resolve "Logon Failed" Error in crystal report

Image
Hi friends, Crystal report is a rich tool of reporting and analysis.when you setup in win application.it works good in development side.but when setup in deployment side come this logon fail error. This error come because crystal report set database connection in report data.and when we change database location or change server then crystal report can't connect with database.so this error come to user. for solution this problem need some code for resolve this issue.this call set login detail to crystal report. //create ReportDocument CrystalDecisions.CrystalReports.Engine.ReportDocument cryRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); //ConnectionInfo ConnectionInfo info = new ConnectionInfo(); //set database server name info.ServerName = Server name; //set database userid info.UserID = userid; //set database password info.Password = password; //set database IntegratedSecurity info.IntegratedSecurity = false; //set report used data...

How to get month days count from date or month and year

Hi all . Window form application need some calculation of date and days,so require no of days in current month or any date of month. So for that we use on c# in build function to get days count. System.DateTime.DaysInMonth(Year(int), Month(int)); This function output number of days in integer. And we need to input year and month number in integer value. If you have date then we get month and year from it. DateTime NowDate = new DateTime(); int iMonth=NowDate.Month; int iYear=NowDate.Year; If you have month name so need to get number of month int iMonth=DateTime.ParseExact("MonthName", "MMMM", CultureInfo.InvariantCulture).Month For this code need to include using System.Globalization; library. Thanks to read this post. comment if any problem in code.

Export datatable data in Excel

Hi to all. Normally we work in database but some time we need reporting or get data in soft copy to send email or for record purpose. So we export data in excel file.hear i show you how to export data from datatable . first get data from database to in datatable which we show in starting session. I genrate one function that help to export in Excel .   public bool DatatabletoExcel(DataTable Dt)         {             bool result = false;             try             {                 //create dialog for create file                 SaveFileDialog sfd = new SaveFileDialog();                 sfd.FileName = "File Name";                 sfd.DefaultExt = "xls";                ...

How to work with comma-separated strings

Hi to all. In this post we introduce with comma separated strings. how we can work with it and manipulate in our work. string language= "C#,Java,Php,python; now we convert it to string array . string[] languageArray= language.Split(','); foreach (string slanguage in languageArray) {     //code what you want     //print slanguage } We can split comma separated string like this.also we can split any character with split function. like language.Split('|'); Thanks for read post. Any problem comment us.

Insert data in AutoNumber DataType (Access Database).

Hi to all. Normally we insert data in table.but when we need some unique identity we use primary key and make  AutoNumber datatype in access database. so when we insert data in database not add column in query of insert. Like table name is Test and columns are Id=>AutoNumber,Name=>Text Query for insert is ="Insert into Test (Name) Values ('TestName')" Hear we not mention Id because Id is AutoNumber. It automatically set last id increment 1.and if we want the inserted id in database after insert query make one code " Select @@Identity "; to execute.         public int InsertData(string sQuary)         {             try             {                 //for get last inserted id                 string sQryIdentity = "Select @@Identity";             ...

Insert date in database by DateTimePicker

Hi to all. If you are new in developing so you have mostly problem to add date in database. so i make code for new beginners. first take one  DateTimePicker name it to Dtdate. Set property Format=Short so we get simple date not in long format. Take one button so on click event we save in database. In Button click event. string Dtdate = Dtdate.Value.ToString("yyyy-MM-dd"); Now the string contain date string in "yyyy-MM-dd" format. on save time make query for date. string sQuary="Insert into testTable (Dtdate) Values (#"+Dtdate +"#)" ; Execute this query. In query I use "#" on start and end. that specify this is date. in database date save always in  "yyyy-MM-dd" format so i convert in this format. Thanks for read this post

Fill List view from database

Image
Hi to all. In this post we make code for populate list view from database. first we take one list view and name them listdata. and set in form with require height and width. listview now make one function FillList() to populate listview.         private void FillList()         {             try             {                 //use dbhelper class to fill datatable from database.                 DbHelper Db = new DbHelper();                 //make query string .                 string sQry = "Select * from Employee";                 //call function for fill datatable.                 DataTable Dt = Db.FillDataTable(sQry);     ...