Monday, April 18, 2011

Refresh the Parent Form on Closing the Child Form in C# Windows Application.

For Example :

Parent Form Contains Grid that displays all Employee data and button Called "Add New Employee". On Add button Click, a Child Page is opening, where we can add a new Employee details, and on save button click, data should be saved in database and child form is closed. At the same time the saved employee data should reflect in the datagrid which is there in parent page.

For these kind of Criteria, please see the code below.
     
On Parent Form :

 private void btnAdd_Click(object sender, EventArgs e)
{
   frmChildForm frm2 = new frmChildForm();
   frm2.FormClosed + = new FormClosedEventHandler(frm2_FormClosed);
   frm2.Show();
 }

 private void frm2_FormClosed(object sender, FormClosedEventArgs e)
 {
   DataTable dt = new DataTable();
   //get Eployee data from db and fill it dt;
   dgvTesting.DataSource =  dt;
   this.Close();
 }

Saturday, March 12, 2011

PHP and MYSQL Interview Question:

1. What is the difference between mysql_fetch_object and mysql_fetch_array?
ans:
mysql_fetch_object() is similar to mysql_fetch_array(), but returns an object instead of an array.i.e. mysql_fetch_object() fetches the first single matching record.
where as mysql_fetch_array() will fetch all matching records from the table in an array.


2. What is the major difference between $_GET and $_POST in php?
ans: $_GET - information sent from a form is visible to every one.
$_POST - information sent from a form is NOT visible to every one, and also there is no limit on the information send.

3. Which function is used for the redirection in PHP?
ans: header()

4. How to retrive a value from MySQL database using php?
ans:
-> $con = mysql_connect("host","username","password");
-> mysql_select_db("db1", $con);
-> $result = mysql_query("query",$con);
-> $row = mysql_fetch_array($result);

5. What is the difference between Primary Key and Unique key?
ans:
Primary key - A colomn in a table, whose value uniquely identifies the rows in the table. Only one primary key for a table and it can not be null.
Unique key - Used to uniquely identify each row in the table. There can be more than one unique keys for a table and it can be null also.

6. What are the advantages of MySQL and PHP?
ans: Both of them are open source and support cross platform. Php is faster than ASP or JSP.

7. How can we submit a form without a submit button?
ans: document.formname.submit();


Saturday, February 26, 2011

Dot net Interview:

1. Which Control has a faster performance?
     a) Data List
     b) Data Grid
     c) Repeater
  Ans: Repeater

2. Base class included in All the webform Pages.
  Ans: System.Web.UI.Page

3. Is String is Value Type OR Referance Type?
  Ans: Reference type.

4. What is Smart Navigation?
  Ans: Cursor position is maintained when the Page gets refreshed due to server side validation. This is called  smart navigation.

5. How ASP.net is different from ASP?
  Ans: In ASP.net scripting is seperated from the HTML code & is compiled as a DLL. This DLL can be executed   on the server.

6. Whst is the use of @page directive?
  Ans: @page directive is used to specify attributes that affects the page in the .aspx page.

7. What is deligates?
  Ans: A deligate is an object that holds the referance to a method.

8. How does asp.net works?
  Ans: When browser requests an asp.net page or file, IIS passes the request to the asp.net engine on the   server. Asp.net engine reads the file line by line, and executes the scripts in the file. Finally the asp.net file is   returned to the browser as a Plain HTML.

9. What is Stored Procedure in SQL?
  Ans: Stored Procdure is already written SQL statments, that is Stored in the database.

10. Explain Execute Scalar in SQL?
  Ans: Executes the query and returns only the first column of the first row in the result set. i.e. It retrives  single value.

11. what is the name space for Unit Testing?
  Ans: Microsoft.VisualStudio.Testtools.Unittesting;

12. Trace and Debug belongs to which namespaces?
  Ans: System.Diagnostics;

13. What are Assemblies?
  Ans: Assemblies are similar to dll files. Both has the reusable pieces of code in the form of classes/ functions. Dll needs to be registered but assemblies have its own metadata.

14. What is code-based security?
  Ans: Determining whether or not a piece of code is allowed to execute & what resources it can use during  execution.

15. Differance between Convert.Tostring() and .Tostring().
  Ans: Both are same, but .Tostring() cant handle null values and will thro null referance exception.
  Where as Convert.tostring() handles null values.