Friday, December 28, 2012

Convert string to date in c#

Below code shows how to convert string which has both date and time to just the date without time.

string value = "1/1/2012 08:15:20";

DateTime dt = Convert.ToDateTime(value);
string shortDate = dt.ToShortDateString();

Accenture WPF interview questions for Experienced people

Accenture WPF Interview Questions

1. What is PRISM,CAL
2.Difference between MVVM,MVC patterns
3. Difference between Delegates and Events..How it is used in WPF Application.
4.How the MVVM Pattern works. Which layer talks to which layer like Model to viewmodel or vice versa?
5.Difference between SQL Server 2008,2005, 2008 R2.
6.Have you worked on SSRS?
7.You have hosted a WCF Service on one machine and if it goes down..what will you do?
8.2 dropdownlists in your WPF User control. if you change value in one dropdown how it will get notified to other dropdown?
9.Different ways of hosting/deploying wpf apps?
10. Have you used WPF Usercontrols in your WPF applications.
11.What are attached properties in WPF?
12. What are Dependency properties in WPF? Give an example where you have used in your project.
13.Is WPF a webbased or windows based application?

Saturday, September 1, 2012

Oracle Tips

1. To Implement Sleep function in PL/SQL use below code:
DBMS_LOCK.SLEEP(10);
2. Any arithmetic expression containing a null always evaluates to null.
3. ORDER BY clause does not affect the ROWNUM of each row.
4. Why use RowNum
a. To limit the no. of rows returned by a query.
b. To assign unique value to each row of a table.
5. In order to create an empty copy of an existing table use below query:
CREATE TABLE new_table AS
SELECT * FROM old_table
WHERE 1 = 2;


SQL> Select the Duplicates with:

SELECT ename,empid FROM Emp
GROUP BY ename, empid
HAVING COUNT(*) > 1;

Delete the Duplicates with

DELETE from Emp A
WHERE (A.ename,A.empid) IN
    (SELECT B.ename, B.empid FROM Emp B
      WHERE A.ename= B.enameAND A.empid = B.empid
       AND A.rowid > B.rowid);


Friday, December 16, 2011

The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access

The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access

Solution: Type the followinf in Visual Studio Command Prompt (Start->All Programs -> Microsoft Visual Studio 2010 -> Visual Studio Tools ->Visual Studio Command Prompt (2010)

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215>aspnet_regiis -ga "NT Authority\Network Service"


This solution works perfectly.

Tuesday, August 30, 2011

About Views

Which of the following statements is correct?

Ans1: CREATE VIEW dbo.vEmpSalTotal AS SELECT EmpId, SUM(EmpSal) FROM [Emp] GROUP BY EmpId
Ans2: CREATE VIEW dbo.vEmpSalTotal AS SELECT EmpId, SUM(EmpSal) as TotalSal FROM [Emp] GROUP BY EmpId
Ans3: The sp_HelpText system stored procedure reveals the code which created an object. For Example below code reveals the View text for the View : "viewGetDetails"

sp_HelpText viewGetDetails.

Ans4: You can Encrypt the view using the "WITH ENCRYPT" keyword in the Create View clause:

ALTER VIEW dbo.viewGetDetailsWITH ENCRYPTION
AS
SELECT
EmpID, SUM(EmpSal) AS TotalSalFROM [Emp]GROUP BY EmpID

Tips to keep updated in IT field.

Friday, August 26, 2011

update database using sqldataadapter


Following code demonstrates simple update to the database, using SqlDataAdapter

var nw = ConfigurationManager.ConnectionStrings["nw"];
var connection = new SqlConnection();
connection.ConnectionString = nw.ConnectionString;
var cmd = connection.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM Customers";
var da = new SqlDataAdapter(cmd);
var nwSet = new DataSet("nw");
var bldr = new SqlCommandBuilder(da);
da.Fill(nwSet, "Customers");
//Modify existing row
var customersTable = nwSet.Tables["Customers"];
var updRow = customersTable.Select("CustomerID='WOLZA'")[0];
updRow["CompanyName"] = "New Wolza Company";
//Add new row
customersTable.Rows.Add(
"AAAAA", "Five A Company");
//Delete a row, note that you cannot delete a
//customer who has orders
var delRow = customersTable.Select("CustomerID='PARIS'")[0];
delRow.Delete();
//send changes to database
da.Update(nwSet, "Customers");
dataGridView2.DataSource = nwSet;
dataGridView2.DataMember = "Customers";
MessageBox.Show("Update Complete");