Monday, December 28, 2015

Date time discussion

Finally i found how to convert time stamp to Date & Date to time stamp . I found some places in project people keep date as time stamp for get difference quickly. so in this case they use to keep the table column as Int or time stamp. now the problem is that in the application while showing the data, you need to convert it into date variable. So for that we can use the following code to convert time stamp to Date
 
int ts = 1451174400;
DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(ts).ToLocalTime();
string formattedDate = dt.ToString("dd-MM-yyyy");
 
Now you can get any date format from this variable.
In the second case if you want to convert Date to time stamp then check the following code.

int ts = (dt.Ticks - 621356166000000000) / 10000000;
Where dt is the date time variable & holding a date value.

If you want to convert string to date find the following code.
DateTime dt = Convert.ToDateTime("2015-12-13");

Saturday, October 24, 2015

SSRS Nested Drill Down Report


Add filter and Parameters in the SSRS report


SSRS Series Part using SQL Server Biseness intelligence

This tutorial is just wonderful if you are learning SSRS report firs time.
This will tell you how to create report -> deploy -> integrate with  your aspx application.

http://www.codeproject.com/Articles/194097/SSRS-Series-Part-I-Various-ways-of-Report-creation

Friday, October 23, 2015

ASP.NET - Single-Page Applications with MVVM Patterns

Hello friends i have found the following tutorial. This is very useful tutorial to know
 Single-Page Applications with MVVM Patterns
https://msdn.microsoft.com/en-us/magazine/dn463786.aspx

Reporting Services permissions on SQL Server

I got this error while i tried to execute report server.
(ser does not have required permissions. Verify that sufficient permissions have been granted and Windows User Account Control (UAC) restrictions have been addressed)
  1. Configure the report server for local administration. To access the report server and Report Manager locally, follow these steps:
  2. Start Windows Internet Explorer.
  3. On the Tools menu, click Internet Options.
  4. Click Security.
  5. Click Trusted Sites.
  6. Click Sites.
  7. Under Add this Web site to the zone, type http://<var>ServerName</var>. If you are not using HTTPS for the default site, click to clear the Require server certification (https:) for all sites in this zone check box.
  8. Click Add.
  9. Repeat step 7f and step 7g to add the http://localhost URL, and then click Close.
  10. Note This step enables you to start Internet Explorer and open either the localhost or the network computer name of the server for both the Report Server application and the Report Manager application.
  11. Create role assignments that explicitly grant you access together with full permissions. To do this, follow these steps:
  12. Start Internet Explorer together with the Run as administrator option. To do this, click Start, click All Programs, right-click Internet Explorer, and then click Run as administrator.
  13. Open Report Manager. By default, the Report Manager URL is http://<var>ServerName</var>/reports.

    If you use SQL Server Express with Advanced Services SP2, the Report Manager URL is http://<var>ServerName</var>/reports$sqlexpress. If you use a named instance of Reporting Services, the Report Manager URL is http://<var>ServerName</var>/reports$<var>InstanceName</var>
  14. In the Home dialog box, click Properties.
  15. Click New Role Assignment.
  16. Type a Windows user account name by using the following format:
    <var>Domain</var>\<var>User</var>
  17. Click to select the Content Manager check box.
  18. Click OK.
  19. In the Home dialog box, click Site Settings.
  20. Click Configure site-wide security.
  21. Click New Role Assignment.
  22. Type a Windows user account by using the following format:
    <var>Domain</var>\<var>User</var>
  23. Click System Administrator.
  24. Click OK.
  25. Close Report Manager.
  26. Use Internet Explorer without the Run as administrator option to reopen Report Manager.
Also, see the following thread (look for post that was marked as answer)

The request failed with HTTP status 401: Unauthorized


I even tried this solution


1. Click Start, click Run, type regedit, and then click OK.
2. In Registry Editor, locate and then click the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
3. Right-click Lsa, point to New, and then click DWORD Value.
4. Type DisableLoopbackCheck, and then press ENTER.
5. Right-click DisableLoopbackCheck, and then click Modify.
6. In the Value data box, type 1, and then click OK.
7. Quit Registry Editor, and then restart your computer.
but it still not working.

Tuesday, April 28, 2015

DataGridView Implementation with DataSet

DataGridView Implementation with DataSet

SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["studentConnectionString"].ConnectionString);
            string sql = "SELECT * FROM student";
            SqlDataAdapter dataadapter = new SqlDataAdapter(sql, connection);
           
            DataSet ds = new DataSet();
            connection.Open();
            dataadapter.Fill(ds, "student");
            connection.Close();
            dataGridView1.DataSource = ds;
           // dataGridView1.DataMember = "student"; //DataMember -- if the DataSet content More than one table then binding the particular table with grid we use this 
            dataGridView1.DataBind();

Visual studio 2013 keybord shortcart

Wednesday, April 22, 2015

Insert in DB C# Dot Net

Please find the following code for connecting with DB

SqlConnection connection = new SqlConnection("Data Source=MACK;Initial Catalog=student;User ID=sa;Password=sourav321");
            SqlCommand command = new SqlCommand();
            command.Connection = connection;

            command.CommandText = "insert into student(id, username, password, name, email) values(@id, @uname, @password, @name, @email)";
            command.Parameters.Add("@uname", UserName.Text);
            command.Parameters.Add("@password", Password.Text);
            command.Parameters.Add("@name", Name.Text);
            command.Parameters.Add("@email", Email.Text);
            command.Parameters.Add("@id", Guid.NewGuid().ToString());
            connection.Open();
            command.ExecuteNonQuery();
            connection.Close();

ASP Dot Net page life Cycle

Page_PreInit -> Page_Init -> Page_InitComplete
Page_PreLoad -> Page_Load
Page_PreRender -> Page_Render