Wednesday 29 February 2012

SQL SERVER 2005 interview question answer


Operation must use an updateable query

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
This error usually happens when you try to insert data into or update data in an Access database. It means that you don't have sufficient permissions to write to the Database.

If you are running the web server yourself then read the FAQ, Checking and Setting up the Correct Permissions on the Server.

If you are not running the server yourself you will need to contact your web space provider and ask them how to sort the problem out. You may need to use a special folder or they may have to setup a system DSN for you or change the permissions on the directory containing the database.

Cannot update. Database or object is read-only.

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only.
This is the most common error that I'm asked about. This error usually happens when you try to insert data into or update data in an Access database. It means that you don't have sufficient permissions to write to the database.

If you are running the web server yourself then read the FAQ, Checking and Setting
up the Correct Permissions on the Server.

If you are not running the server yourself you will need to contact your web space provider and ask them how to sort the problem out. You may need to use a special folder or they may have to setup a system DSN for you or change the permissions on the directory containing the database.

AjaxControlToolkit is undefined OR Sys' is undefined error in ASP.NET AJAX

adding this under httpHandlers:

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Turns out in the web.config nestled under <system.webServer> / <handlers>, I was missing this entry:

<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

When we get Error 'HTTP 502 Proxy Error' ?

We get this error when we execute ASP.NET Web pages in Visual Web Developer Web server, because the URL randomly select port number and proxy servers did not recognize the URL and return this error. To resolve this problem we have to change settings in Internet Explorer to bypass the proxy server for local addresses, so that the request is not sent to the proxy.

Operation must use an updateable query" error

Reason: Your database is in a folder where there is no write/change permission.
Resolution:
If using Windows 2000 - IIS5- the {Server}\ASPNET User Account must have Read, Write, and Change Control of the Folder where database resides
If using Windows 2003 - IIS6- the NETWORK SERVICE User Account must have Read, Write, and Change Control of the Folder where database residesGiving EVERYONE account full control will solve your problem too but Never do that as it will expose your system to external attacks within network.

Failed to load viewstate

cause
The exception occurs because the viewstate of the page must be restored to its previous state. This mean we need to re-load any control we loaded dynamically before the page load had being triggered.

Solution :
I was able to get it working by setting the PlaceHolder that I was dynamically adding the control to EnableViewState="False".
Set EnableViewStage=”false” in Page Directive

Deleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified.

Solution:

if you need to pass parameters, then use the deleteparameters collection of the control.

get error message Validation of viewstate MAC failed

You have an ASP.NET web application running on a web-farm that does not use sticky sessions - so the requests for a session are not guaranteed to be served the same machine. Occasionally, the users get error message Validation of viewstate MAC failed. What could be one reason that is causing this error?
The most common reason for this error is that the machinekey value in machine.config is different for each server. As a result, viewstate encoded by one machine cannot be decoded by another. To rectify this, edit the machine.config file on each server in the web-farm to have the same value for machinekey.

What does the "Access is Denied" IE error mean?

The "Access Denied" error in any browser is due to the following reason.A javascript in one window or frame is tries to access another window or frame whose document's domain is different from the document containing the script.

Why innerText not working in Firefox

Use innerHTML instead of innerText

Cannot use a leading .. to exit above the top directory

When I do a server.mappath on ../../private, I get this error:Cannot use a leading .. to exit above the top directory.

try to use Server.MapPath("~/private"). It is more reliable. What willhappen when u add another subdirectory... Server.MapPath("~/private") willstill works.

Is there any way to get detailed error information for Win32 errors when using Platform Invoke?

Yes, you can use the FormatMessage Win32 API. Sample projects for C# and VB.NET are enclosed. This is how the declaration looks like:

[DllImport("Kernel32.dll")]

public static extern int FormatMessage(int flags, IntPtr source, int messageId, int languageId, StringBuilder buffer, int size, IntPtr arguments );

Called like so:

// You can call FormatMessage to get a descriptive error message

StringBuilder sbFormatMessage = new StringBuilder(1024);

retVal = Interop.FormatMessage(Interop.FORMAT_MESSAGE_FROM_SYSTEM, IntPtr.Zero, Marshal.GetLastWin32Error(), 0, sbFormatMessage,

sbFormatMessage.Capacity, IntPtr.Zero);

I get an error message "Property cannot be assigned to -- it is read only". How can I set this read only property?

When I try to set a particular font style, say italics, I get an error message "Property cannot be assigned to -- it is read only". How can I set this read only property?


Code such as

tabControl1.Font.Italic = true;

will not work. Instead, you have to create a new Font object, and set the property during its creation. This code
will work.

tabControl1.Font = new Font(tabControl1.Font, FontStyle.Italic);

I get a 'This would cause two bindings in the collection to bind to the same property' error message. What might cause this?

As the message suggests, the code is calling Control.DataBindings.Add twice with what amounts to the same parameters.One way this might happen is if you call the same code more than once in your program to reload your datasource for some reason, and in this code, you have lines such as:

Me.TextBox1.DataBindings.Add("Text", myDataTable, "Col1Name")
Me.TextBox2.DataBindings.Add("Text", myDataTable, "Col2Name")
Me.TextBox3.DataBindings.Add("Text", myDataTable, "Col3Name")

On the second call, this would attempt to add a duplicate binding to the DataBindings collection. One solution is to Clear the DataBindings collection before you add your new binding.

Me.TextBox1.DataBindings.Clear();
Me.TextBox1.DataBindings.Add("Text", myDataTable, "Col1Name")
Me.TextBox2.DataBindings.Clear();
Me.TextBox2.DataBindings.Add("Text", myDataTable, "Col2Name")
Me.TextBox3.DataBindings.Clear();
Me.TextBox3.DataBindings.Add("Text", myDataTable, "Col

When I try to update a dataset I get an error that the system is unable to find "Table"?

Are you calling Update on the dataset like this without specifying the name of the table that you are updating. The problem is that when table names are not given the system assumes a table name of 'Table'. This of course causes the update to fail.

this.dataAdapter.Update(this.dataSet);

If so just change this line to

this.dataAdapter.Update(this.dataSet, "Customers");

// replace 'Customers' with the table that you have

In C++, the code "MyClass ht;" creates an object ht on the stack frame. But in C#, this same code compiles, but gives a runtime error. Why?

MyClass ht; does not create any object. Instead, it creates a variable (a reference) of type MyClass, and sets its value to null. No object is created. To create an object, you need to explicitly call the class contructor with a new.

MyClass ht = new MyClass();

You can also use ht to refer to an instance of MyClass that has been created (with a new) at some other point in your code.

MyClass myClass = new MyClass();

MyClass ht;

ht = myClass; // both ht and myClass are references to the same object...

How can I get rid of the error icon that appears when there is an editing error?

DataTable dt = (DataTable)dataGrid1.DataSource;

foreach(DataRow row in dt.GetErrors())

{

row.RowError = "";

foreach(DataColumn col in dt.Columns)

row.SetColumnError(col, "");

}

session does not working in Web Service

The EnableSession property of the WebMethod attribute enables session state for an XML Web service method. Once enabled, the XML Web service can access the session state collection directly from HttpContext.Current.Session or with the WebService.Session property.

in VB.NET

_

in C#

[System.Web.Services.WebMethod(EnableSession=true)]

Parse error: parse error, unexpected T_STRING

Cause of Error
The problem is the syntax of your code, perhaps you forgot a semi-colon on one of the lines.

How to Fix Them
If you notice that you forgot a simple semi-colon, then insert it and you'll be on your way.

 

Internet Explorer cannot download MyPage.aspx from MyWebSite.com

Why do I get error message "Internet Explorer cannot download MyPage.aspx from MyWebSite.com ..."?

This happens for example, whe you try to export data to excel from a datagrid.
The problem occurs if the server is using Secure Sockets Layer (SSL) and has added one or both of the following HTTP headers to the response message:

Pragma: no-cache
Cache-control: no-cache,max-age=0,must-revalidate

Unable to find script libruary 'WebUIValidation.js'

Why do I get the "Unable to find script libruary 'WebUIValidation.js'" error ?

When you install the .Net framework on your web server, it installs some script files (including the above) under the root folder (usually "C:\inetput\wwwroot" if you do a default installation) . You can then find the above file at "C:\Inetpub\wwwroot\aspnet_client\system_web\1_1_4322", for example.

The above problem could happen if you reconfigured your web root directory to be a different one after you installed ASP.Net in your web server. If that is the case, then run 'aspnet_regiis -c' (utility is under %windir%\Microsoft.NET\Framework\v1.1.4322, for example) or copy over manually the above script files into a similar sub-directory below your current web root directory. Also, if you look at the error message in detail, you will notice where the file is supposed to be.


Why do I get error message "Error creating assembly manifest: Error reading key file 'key.snk' -- The system cannot find the file specified"?

Check the location of the key.snk file relative to the assembly file. Provide an explicit path or a relative path.

Assembly: AssemblyKeyFileAttribute("Drive:\key.snk")

Compiler Error Message: BC30289

My ASP code gives an error "Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed" when changed to .aspx?

Use a script runat=server block instead of the Delimeter syntax to define Subs.Make sure you have proper events associated with the code and have start and end of procedure or function wirtten properly.

How to catch the 404 error in my web application and provide more useful information?

In the global.asax Application_error Event write the following code

VB.NET

Dim ex As Exception = Server.GetLastError().GetBaseException()
If TypeOf ex Is System.IO.FileNotFoundException Then
'your code
'Response.Redirect("err404.aspx")
Else
'your code
End If

C#

Exception ex = Server.GetLastError().GetBaseException();
If (ex.GetType() == typeof(System.IO.FileNotFoundException))
{
//your code
Response.Redirect ("err404.aspx");
}
else
{
//your code
}

Why do I get the "Unable to find script libruary 'WebUIValidation.js'" error ?

When you install the .Net framework on your web server, it installs some script files (including the above) under the root folder (usually "C:\inetput\wwwroot" if you do a default installation) .

You can then find the above file at "C:\Inetpub\wwwroot\aspnet_client\system_web\1_1_4322", for example.

The above problem could happen if you reconfigured your web root directory to be a different one after you installed ASP.Net in your web server. If that is the case, then run 'aspnet_regiis -c' (utility is under %windir%\Microsoft.NET\Framework\v1.1.4322, for example) or copy over manually the above script files into a similar sub-directory below your current web root directory. Also, if you look at the error message in detail, you will notice where the file is supposed to be.

Server Application Unavailable

Why do I get the error message "Server Application Unavailable The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request."?

By default, ASP.NET runs its worker process (Aspnet_wp.exe) with a weak account (the local machine account, which is named ASPNET) to provide a more secure environment. On a domain controller or on a backup domain controller, all user accounts are domain accounts and are not local machine accounts. Therefore, Aspnet_wp.exe fails to start because it cannot find a local account named "localmachinename\ASPNET". To provide a valid user account on the domain controller, you must specify an explicit account in the section of the Machine.config file, or you must use the SYSTEM account.

Why do I get "HTTP 500" error (or "(DLL) initialization routine failed") in my browser?

This is because if you have the /3GB boot switch enabled, the ASP.NET worker process (Aspnet_wp.exe) does not start. To create and set the "ASPNETENABLE3GB" environment variable as mentioned in the above article, right click MyComputer ->Properties->Advanced > Environment Variables > System variables > New. Add the variable name in the top text box and the value in the lower textbox.

Invalid postback or callback argument

Try adding this into the system.web section of your web.config file:
pages enableEventValidation="false"

@ Page Language="C#" MasterPageFile="~/Admin/MasterPage_Admin.master" AutoEventWireup="true" CodeFile="CategoryManagement.aspx.cs" Inherits="Admin_CategoryManagement" Title="Untitled Page" EnableEventValidation="false"
You can also benefit from those features by leaving it enabled then register your control for event validation. Simply add the following call in the PreRender or Render page life cycle then your control should work without having to turn off eventValidation:Page.ClientScript.RegisterForEventValidation(this.UniqueID);

Sys.WebForms.PageRequestManagerParserErrorException

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

If your Response.Redirect doesn’t work under UpdatePanel’s callback, then you definitely missing ScriptModule in the web.config:
in httpmodules tag
add type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="ScriptModule"
close tag httpmodules

error that says the BIOS limit has been exceeded

When I try to run pages on a remote computer using the ASP.NET Development Server, I get an error that says the BIOS limit has been exceeded. What is the problem?

You might see this error if the remote computer is running Windows 2000 or Windows XP. If the remote computer is running Windows 2000, you can follow the instructions in Microsoft KnowledgeBase article 810886 to set the maximum number of concurrent connections to a higher number. If you are running Windows XP, you might be able to avoid this error by closing existing shared resources, including terminal server sessions, on the remote computer. (Windows XP is configured with a fixed number of maximum concurrent network requests.)

error "The page cannot be displayed" and an HTTP 502 Proxy Error

When I run a page, I get the error "The page cannot be displayed" and an HTTP 502 Proxy Error. Why?

This error can occur if you are running ASP.NET Web pages using the Visual Web Developer Web server, because the URL includes a randomly selected port number. Proxy servers do not recognize the URL and return this error. To get around the problem, change your settings in Internet Explorer to bypass the proxy server for local addresses, so that the request is not sent to the proxy. In Internet Explorer, you can make this change in Tools > Internet Options. In the Connections
tab, click LAN Settings and then select Bypass proxy server for local addresses.

There was an error reflecting MyClass

XmlSerializer is throwing a generic "There was an error reflecting MyClass" error. How do I find out what the problem is?

Look at the InnerException property of the exception that is thrown to get a more specific error message.

Why do I get errors when I try to serialize a Hashtable?

XmlSerializer will refuse to serialize instances of any class that implements IDictionary, e.g. Hashtable. SoapFormatter and BinaryFormatter do not have this restriction.

I'm having some trouble with CAS. How can I troubleshoot the problem?

Caspol has a couple of options that might help. First, you can ask caspol to tell you what code group an assembly belongs to, using caspol -rsg. Similarly, you can ask what permissions are being applied to a particular assembly using caspol -rsp.

get the error System.__ComObject

I get the error System.__ComObject when using recordset?

This error occurs if you are trying to fetch the recordset value as follows

rs.Fields("productname")

To avoid this error try

VB.NET

rs.Fields("productname").Value.ToString()

C#

rs.Fields["productname").Value.ToString() ;

Why do I get error "A generic error occurred in GDI+." when trying to save the bitmap file?

May be the path of the file you are giving is wrong or you do not have write permissions on the specific folder.

My ASP code gives an error "Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed" when changed to aspx

Use a script runat="server" block instead of the <% %> syntax to define Subs.Make sure you have proper events associated with the code and have start and end of procedure or function wirtten properly.

Why do I get error message "Error creating assembly manifest: Error reading key file 'key.snk' -- The system cannot find the file specified"?

Check the location of the key.snk file relative to the assembly file. Provide an explicit path or a relative path.



Why do I get the "Unable to find script libruary 'WebUIValidation.js'" error ?

When you install the .Net framework on your web server, it installs some script files (including the above) under the root folder (usually "C:\inetput\wwwroot" if you do a default installation) . You can then find the above file at "C:\Inetpub\wwwroot\aspnet_client\system_web\1_1_4322", for example.

The above problem could happen if you reconfigured your web root directory to be a different one after you installed ASP.Net in your web server. If that is the case, then run 'aspnet_regiis -c' (utility is under %windir%\Microsoft.NET\Framework\v1.1.4322, for example) or copy over manually the above script files into a similar sub-directory below your current web root directory. Also, if you look at the error message in detail, you will notice where the file is supposed to be.

error message "It is already opened exclusively by another user, or you need permission to view its data." when I try to open Access mdb?

The ASPNET worker process doesn't have the correct permissions to connect to or write to the Access database. Either enable impersonation for users or configure the ASP.NET worker process to run under the SYSTEM account. You can also grant read and write permissions for the "Everyone" group on the database and the database folder.

Why do I get the Error Message "System.OutOfMemoryException: Exception of type System.OutOfMemoryException was thrown."?

It means that the server is out of available memory. You probably have an infinite loop somewhere that's frantically creating large objects, or you forgot to dispose of disposable objects and memory slowly leaked.

"Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection"?

This error usually indicates that SQLServer (or MSDE) is configured to use Windows Authentication. If you want to use a SQL login, you will need to enable SQL Authentication (mixed mode authentication).

What is Stored Procedure?

A stored procedure is a named group of SQL statements that have been previously created and stored in the server database. Stored procedures accept input parameters so that a single procedure can be used over the network by several clients using different input data. And when the procedure is modified, all clients automatically get the new version. Stored procedures reduce network traffic and improve performance. Stored procedures can be used to help ensure the integrity of the database. e.g. sp_helpdb, sp_renamedb, sp_depends etc.

What are different normalization forms?

1NF: Eliminate Repeating Groups
Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.
2NF: Eliminate Redundant Data
If an attribute depends on only part of a multi-valued key, remove it to a separate table.
3NF: Eliminate Columns Not Dependent On Key
If attributes do not contribute to a description of the key, remove them to a separate table. All
attributes must be directly dependent on the primary key
BCNF: Boyce-Codd Normal Form
If there are non-trivial dependencies between candidate key attributes, separate them out into distinct tables.
4NF: Isolate Independent Multiple Relationships
No table may contain two or more 1:n or n:m relationships that are not directly related.
5NF: Isolate Semantically Related Multiple Relationships
There may be practical constrains on information that justify separating logically related many-to-many relationships.
ONF: Optimal Normal Form
A model limited to only simple (elemental) facts, as expressed in Object Role Model notation.
DKNF: Domain-Key Normal Form
A model free from all modification anomalies.
Remember, these normalization guidelines are cumulative. For a database to be in 3NF, it must first fulfill all the criteria of a 2NF and 1NF database.

What is normalization?

Database normalization is a data design and organization process applied to data structures based on rules that help build relational databases. In relational database design, the process of organizing data to minimize redundancy. Normalization usually involves dividing a database into two or more tables and defining relationships between the tables. The objective is to isolate data so that additions, deletions,and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.

What is RDBMS?

Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers.
This allows a high degree of data independence. An RDBMS has the capability to recombine the data items from different files, providing powerful tools for data usage.

Before a user can build reports using Report Builder in Reporting Services 2005, which one of the following steps must be done first?

Build and deploy a modelReport Builder requires a model and that model cannot be defined using Report Builder. The advantage of using models is that users do not need to understand SQL statements to build a report (but they will still benefit from a basic understanding of the relationships between various bits of data)

Where are Notification Services event messages logged in SQL Server 2005?

In the Windows Application Log
Event messages are logged in the Windows Application log.

The TRUSTWORTHY database property is by default?

Off
The correct answer is off – The TRUSTWORTHY database property indicates whether the installed instance of SQL Server trusts the database such that it can reach out and perform actions outside the database. By default it is OFF such that the database to reduce certain threats that can result from attaching a database that contains potentially harmful code

In the SQL Server 2005 thesaurus XML configuration file, what is the expansion set?

Expansion sets are synonyms for the search term and returned as results if they appear along with the search term.
The expansion set is the group of values that are synonyms and can be substituted for the search term. For example, an expansion set can be "SS2K5", "SQL Server 2005", "SQL2K5". In this case, fields with any of these 3 values would be returned as a result for searches on "SQL Server 2005".

Native Web Services require what type of endpoint in SQL Server 2005?

HTTP endpoints
Native XML Web Services in SQL Server 2005 require HTTP endpoints to communicate with clients.

In Reporting Services 2005, how is Report Builder typically deployed to end users?

One click deployment launched from a menu on the Report Manager home page
One click deployment is fast and easy, users click the menu on the Report Manager page. It is not a web application, but rather a .Net Winform application.

trigger assigned to it?

Yes
An event can have multiple triggers assigned to it.

Out of the box Report Builder supports two report level fields that can be shown on a report. Which option below has those two options?

The current filter and the number of rows that matched that filterBy default, the current filter definition and the number of rows that matched the filter are added to the end of the report. They can be removed and added back as needed.

Which utility is used to administer SQL Server 2005 Notification Services instances?

nscontrol.exe
The nscontrol application can be used with various parameters to administer a SQL Server 2005 Notification Services instance.

You have noticed in both your SQL Server 2000 and 2005 instances that when a database grows in SQL Server, there is a delay in the database response.

Once the file is grown, zeros are written to the new space, causing a delay.When a database file grows, unless instant file initialization is turned on, the server must allocate disk space and then write 0s into all that space. This zero-ing out of the file creates the delay.

Using Reporting Services 2005, it is true or false that subreports execute a query against the datasource once for every detail row in the report?

True
True. Subreports can be used for a master-detail relationship, or the subreport can be a separate item, but in either case RS will query to get the data for the report once for each detail row. If end users are going to only occasionally look at the data you're displaying in the subreport or only view it for a few rows, a better option is to create a link to the other report.

On which platforms can you use Instant File Initialization to improve database growth performance in SQL Server 2005?

Windows 2003 and XP Pro
Both Windows 2003 Server and later as well as Windows XP Professional support Instant
File Initialization.

Which RAID levels store parity information?

RAID 5
Only RAID 5 (of those listed) contains parity information.

True or false, Report Builder supports using the LIKE function inside filters?

False
There is no LIKE support, the next best thing is the CONTAINS function which works as if you specified both a leading and trailing wild card.

Using Report Builder, which of the following statements is correct about formatting numbers?

Users can pick from a small number of predefined formats and they have the option to specify a custom format
There are give built in formats; general, currency, percentage, two place decimal, and exponent. Users can also define a custom format using a .Net format string.

Which of the following choices show the three report formats supported by Report Builder ?

Table, Matrix, Chart
Report Builder can build a report formatted as a table, chart, or matrix (cross tab), but only ONE can be used in any given report.


No comments:

Post a Comment