Skip to main content

Posts

Showing posts from June, 2011

LIKE Condition : SQL SERVER

The LIKE condition allows you to use wildcards in the where clause of an SQL statement. This allows you to perform pattern matching. The LIKE condition can be used in any valid SQL statement - select, insert, update, or delete. The patterns that you can choose from are: % allows you to match any string of any length (including zero length) _ allows you to match on a single character Examples using % wildcard The first example that we'll take a look at involves using % in the where clause of a select statement. We are going to try to find all of the suppliers whose name begins with 'Hew'. SELECT * FROM suppliers WHERE supplier_name like 'Hew%'; You can also using the wildcard multiple times within the same string. For example, SELECT * FROM suppliers WHERE supplier_name like '%bob%'; In this example, we are looking for all suppliers whose name contains the characters 'bob'. You could also use the LIKE condition to find suppliers ...

SQL ALTER TABLE

The SQL ALTER TABLE command is used to modify the definition (structure) of a table by modifying the definition of its columns. The ALTER command is used to perform the following functions. 1) Add, drop, modify table columns 2) Add and drop constraints 3) Enable and Disable constraints Syntax to add a column ALTER TABLE table_name ADD column_name datatype; For Example: To add a column "address" to the student table, the query would be like ALTER TABLE employee ADD address varchar(500); Syntax to drop a column ALTER TABLE table_name DROP column_name; For Example: To drop the column "age" from the student table, the query would be like ALTER TABLE employee DROP age;  Syntax to modify a column ALTER TABLE table_name MODIFY column_name datatype; For Example: To modify the column fees in the student table, the query would be like ALTER TABLE employee MODIFY fees number(15,2); SQL RENAME Command The SQL RENAME command is used to change the na...

Asp.Net :How to clear all ASP.Net control content in one method C#

You can call this function to clear content of  controls such as TextBox, CheckBox and  DropDownList. You can further add on other ASP.Net controls to clear their content. public void ClearFields(System.Web.UI.Page page, string defaultDropDownValue) { ArrayList all = GetControls(page.Controls); for (int i = 0; i Many Asp.Net new programmer do it by clear  control content by setting their property one by one . For Ex. TextBox1.Text=""; checkBox1.checked=False;

Web Services :ASP.Net

Web Services, a technology that is part of ASP.NET. Through Web Services you can make your processing methods available and executable by others on the Web, and you can execute methods on your pages that are made available by others. The general idea is that Web page processing can be handled by your scripts or by scripts housed anywhere on the Web. Web Services Development Process In its most simple form, a Web Service is a Visual Basic function that can be called from anywhere on the Web. The function is created and accessed through the following steps. As the supplier of a Web Service,  Create a Visual Basic class that encapsulates your processing function, much as you would for a local function designed for use from your own Web pages.  Convert the class to a Web Service by including special code to identify it as such,saving the class as a .asmx file in a Web-accessible directory. Make the URL to your Web Service available to others who wish to use it.In this way...

How to generate Sitemap for blogger

This is very simplest way to submit your blogspot blog  sitemap to webmaster. Login into your google webmaster click on submit a sitemap and copy this line into the given input box. atom.xml?redirect=false&start-index=301&max-results=100 for 300+posts. But 300 posts nicely have indexed by Google,but more than 300,it is not indexing.

Interview Questions on DotNet Framework

1. What is CLR? The .NET Framework provides a runtime environment called the Common Language Runtime or CLR (similar to the Java Virtual Machine or JVM in Java), which handles the execution of code and provides useful services for the implementation of the program. CLR takes care of code management at program execution and provides various beneficial services such as memory management, thread management, security management, code verification, compilation, and other system services. The managed code that targets CLR benefits from useful features such as cross-language integration, cross-language exception handling, versioning, enhanced security, deployment support, and debugging. 2. What is CTS? Common Type System (CTS) describes how types are declared, used and managed in the runtime and faci...

Sharekhan Lightweight Website SharekhanMini for Slow Internet

Introduction of SharekhanMini https://strade.sharekhan.com/rmmweb/mini/   SharekhanMini intend to give our Low Bandwidth Users  a complete (NSE/BSE/NSEFO) solution on the handsets , hence we call it “Sharekhan Mini” aka Low Bandwidth Web Site. What SharekhanMini wish to present is the extremely user friendly UI and rocking speedy website. This might look contradictory to the above statement as it was meant for people having sorry internet connectivity. “Yes” But on a free way like a broadband/corporate internet this website works faster than the classic one’s, reason being its customized to work on low fuel and when you put it on nitro it glides.These are basic facts about Sharekhanmini. Low bandwidth can be due to: 1) Rural areas where high speed connections are not available or 2) Financial situation- that is, expensive high-speed connection 3) Some older technologies load pages very slowly and do not support features used on newer s...

Explanation of SQL Command GO

GO is not a Transact-SQL statement; it is often used in T-SQL code. Go causes all statements from the beginning of the script or the last GO statement (whichever is closer) to be compiled into one execution plan and sent to the server independent of any other batches. SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is the first GO. GO Statement must be written in new line as it is not T-SQL command. T-SQL statement can not occupy the same line as GO. GO statement can contain comments. Following is example for SQL SERVER 2005 for database Adventureworks. USE AdventureWorks ; GO DECLARE @MyMsg VARCHAR ( 50 ) SELECT @MyMsg = ‘Hello,You are in new World.’ GO —- @MyMsg is not valid after this GO ends the batch. —- Yields an error becaus...

Check Textbox input is Numeric , VB.Net

Many new programmer face a problem to checking whether textbox input is numeric or not. So you can easily implement this code on your windows forrm. Call this function on textbox1_Keypress event and it will prevent to enter non-numeric character in textbox. <code>Public Function Check_number(ByVal ch As Char) As Boolean On Error GoTo handle If Asc(ch) = 8 Then Check_number = False Exit Function End If If IsNumeric(ch) = False Then Check_number = True Exit Function End If Check_number = False Exit Function handle: LoadError("Check_number") End Function</code> Call this function as follows <code>Private Sub txtbox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtbox1.KeyPress e.Handled = Check_number(e.KeyChar) End Sub</code>

Check Textbox input is Numeric , C#.Net

Many new programmer face a problem to checking whether textbox input is numeric or not. So you can easily implement this code on your windows form. Call this function on textbox1_Keypress event and it will prevent to enter non-numeric character in textbox.This code only accept integer value and works in Window Application. <code><span>public static bool CheckNumber(char ch) { if (Convert.ToInt32(ch) == 8 ) return false; if(char.IsDigit(ch)==false) return true; return false; }</span></code> Call this function as follows <code>private void txtBox1_KeyPress(object sender, KeyPressEventArgs e) { e.Handled = CheckNumber(e.KeyChar, ((TextBox)sender).Text); }</code>

COUNT Function - SQL Server

The COUNT function returns the number of rows in a query. The syntax for the COUNT function is:   <code>  SELECT COUNT(expression)     FROM tables     WHERE predicates;</code> Note: The COUNT function will only count those records in which the field in the brackets is NOT NULL. For example, if you have the following table called suppliers:   <code>  Supplier_ID     Supplier_Name     State     1     IBM     CA     2     Microsoft         3     NVIDIA      </code> The result for this query will return 3. <code>    Select COUNT(Supplier_ID) from suppliers;</code> While the result for the next query will only return 1, since there is only one row in the suppliers table where the State field is NOT NUL...

SQL: UPDATE Statement

The UPDATE statement allows you to update a single record or multiple records in a table. The syntax for the UPDATE statement is:   <code>  UPDATE table     SET column = expression     WHERE predicates;</code> Example #1 - Simple example Let's take a look at a very simple example.    <code> UPDATE suppliers     SET name = 'HP'     WHERE name = 'IBM';</code> This statement would update all supplier names in the suppliers table from IBM to HP. Example #2 - More complex example You can also perform more complicated updates. You may wish to update records in one table based on values in another table. Since you can't list more than one table in the UPDATE statement, you can use the EXISTS clause. For example:  <code>   UPDATE suppliers         SET supplier_name =     ( SELECT customers.name ...

SQL: EXISTS Condition

The EXISTS condition is considered "to be met" if the subquery returns at least one row. The syntax for the EXISTS condition is:     <code>SELECT columns     FROM tables     WHERE EXISTS ( subquery );</code> The EXISTS condition can be used in any valid SQL statement - select, insert, update, or delete. Example #1 Let's take a look at a simple example. The following is an SQL statement that uses the EXISTS condition:    <code> SELECT *     FROM suppliers     WHERE EXISTS       (select *         from orders         where suppliers.supplier_id = orders.supplier_id);</code> This select statement will return all records from the suppliers table where there is at least one record in the orders table with the same supplier_id. Example #2 - NOT EXISTS The EXISTS condit...

Conditionaly combine databound fields : ASP.NET

I have a Gridview ItemTemplate which displays company info as follows <ItemTemplate> <asp:Label ID="WEmployerLabel" runat="server" Text='<%# Bind("Employer") %>'></asp:Label><br /> <asp:Label ID="WAddress1Label" runat="server" Text='<%# Bind("WAddress1") %>'></asp:Label><br /> <asp:Label ID="WCityLabel" runat="server" Text='<%# Bind("WCity") %>'></asp:Label><br /> <asp:Label ID="WPhoneTextLabel" runat="server" Text="Phone: "></asp:Label><asp:Label ID="WPhoneLabel" runat="server" Text='<%# Bind("WPhone") %>'></asp:Label> </ItemTemplate> The problem is that if a column is blank the <br/> is still appended so the cell is taller then it needs to be and I have less space to displ...

Not associated with a trusted SQL Server connection

This error can come due to a couple of reasons. The most common reason is that the instance that you are trying to connect to has been set up as one with only Windows Only Authentication rather than Windows and SQL Server Authentication. You can check that easily by either by SSMS (SQL Server Management Studio) or in the registry settings as well (in case you do not have the client tools loaded up on the instance where you are getting this error and you inherited this set up from someone). In SSMS, after you log in using your Windows Authentication, right click on the server and choose “Properties” and then go to the Security page and change the “Server Authentication” to be “SQL Server and Windows Authentication mode” . Once that is done, you will need to re-start the MSSQLServer service in order for the changes to take place. The place where it gets stored in the registry is: HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL.2005\MSSQLServer LoginMode – if it is ...