Posts

How to write and read from Registry in C#?

Image
Local data storage in client machine developer use registry.this store small data like application settings.It can modify manually to edit in regedit . In this post we learn about read and write in registry.Registry is one structure of data by link or keys and sub keys. For write in registry need to create key or path where want to write.so if we have key then open it and not then create it. RegistryKey Newkey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\NewKey"); Registry.CurrentUser => "\HKEY_CURRENT_USER\" @"SOFTWARE\KeyName" => this key is located on "HKEY_CURRENT_USER\Software\NewKey" CreateSubKey() => create new key RegistryKey Key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Key",true); OpenSubKey() => opne allready exist Key OpenSubKey(@"SOFTWARE\Key",true) => OPen "HKEY_CURRENT_USER\SOFTWARE\Key" and second parameter "True" is allow write keys otherwise not permit ...

How to reset Autonumber column from 1 after delete all table data in MS Access?

Image
MS Access is basic and stander database for developers.essay to use and work. Normally like work in excel.now we discuss for our topic "How to reset Autonumber column from 1 after delete all table data in MS Access?". Some time developers work on db and after deployment time need to reset or blank database for user use.no testing data in it.so developers need to reset identity ( Primary,Autonumber  ) column.for that need to query on db for reset to 1 or want to any numbers. "ALTER TABLE # yourTable # ALTER COLUMN # column-name # COUNTER(1,1)" Execute this query with edit your table name and column name. You can also set gaps in increment and set start of numbers.like want to start from 1001 and gap with 10 then this is possible to do in. Related Post How to get html of web page in string by web page url. Export datatable data in Excel Fill datatable from access database CRUD Operations in win form application with access database

How to get html of web page in string by web page url

Image
           Hi friends sometimes we need a content of web page like text or links and many more things.then we use the html of page by inspect elements.            Now that we do by c# code.this work on both web and window application. First include library of " using System.Net; " Second code for one line. string strhtml = new WebClient().DownloadString("http://facebook.com"); This returns string of all web page html in string. We can manipulate string and get we require content.

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.