Hi
This the Solution I found For the Following Problem
Normally You Will Find That When You have any dataentry form in asp.net with GridView you have many fields in that
suppose you have field of First Name and submit button
If you enter the Name as eg. Mrugank Dholakia and submit it It will be saved in database same way
if you again add the same name with spaces eg Mrugank Dholakia and submit it It will saved in database
But When You will see in the GridView It will Look Same as
Mrugank Dholakia
Mrugank Dholakia
Actucally It stores second one in database with spaces but still this is the situation
What Happens behind this is the problem of Browser IE and Mozilla which automatically trims the extra spaces between the words
To avoid this This is the below mention solution
1 )First While Featching From the Database you have to Replace spaces with using Replace function of Asp.NET
Variable.Replace(" "," ");
2) User The HtmlDecode method of HTTPServer Utility
Server.HTMLDecode(Variable);
Here variable is the value comming from the database
Sample Code:
protected void gvCustNames_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
String str=Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Name"));
str=str.Replace(" ", " ");
((
Label)(e.Row.FindControl("lblName"))).Text = Server.HtmlDecode(str);
}
}
Regards
Mrugank Dholakia
(MCA) Software Engineer
Saturday, September 27, 2008
Active Connection With SQL Server 2005
Hi
I found This Good One It May Help You
At times, we need to check the number of active connections for each Database on our server. This can be done easily using the following script. The script displays the DatabaseName, the number of connections and the login name :
SELECT db_name(dbid) as DatabaseName, count(dbid) as NoOfConnections,
loginame as LoginName
FROM sys.sysprocesses
WHERE dbid > 0
GROUP BY dbid, loginame
Regards
Mrugank Dholakia
(MCA) Software Engineer
I found This Good One It May Help You
At times, we need to check the number of active connections for each Database on our server. This can be done easily using the following script. The script displays the DatabaseName, the number of connections and the login name :
SELECT db_name(dbid) as DatabaseName, count(dbid) as NoOfConnections,
loginame as LoginName
FROM sys.sysprocesses
WHERE dbid > 0
GROUP BY dbid, loginame
Regards
Mrugank Dholakia
(MCA) Software Engineer
Pivot Table Concept in SQL Server 2005
Pivot is a very good concept of converting Row to columns in SQL Server 2005
It is Very Helpful way When the no of colums are fixed which is to be converted from rows
-- Creating Test TableCREATE TABLE Product(Cust VARCHAR(25), Product VARCHAR(20), QTY INT)GO -- Inserting Data into TableINSERT INTO Product(Cust, Product, QTY) VALUES('MALAY','VEG',2)INSERT INTO Product(Cust, Product, QTY) VALUES('MALAY,'SODA',6)INSERT INTO Product(Cust, Product, QTY) VALUES('MALAY,'MILK',1)INSERT INTO Product(Cust, Product, QTY) VALUES('MALAY','BEER',12)INSERT INTO Product(Cust, Product, QTY) VALUES('MILAP','MILK',3)INSERT INTO Product(Cust, Product, QTY) VALUES('MILAP','BEER',24)INSERT INTO Product(Cust, Product, QTY) VALUES('MALAY','VEG',3)GO SELECT * FROM Product
ResultCust Product QTY
------------------------- -------------------- -----------
MALAY VEG 2
MALAY SODA 6
MALAY MILK 1
MALAY BEER 12
MILAP MILK 3
MILAP BEER 24
MALAY VEG 3
GO SELECT CUST, VEG, SODA, MILK, BEER FROM ( SELECT CUST, PRODUCT, QTY FROM Product) up PIVOT (SUM(QTY) FOR PRODUCT IN (VEG, SODA, MILK, BEER)) AS pvt ORDER BY CUSTGO
Result
CUST VEG SODA MILK BEER
--------------- -------- ----------- -------- -----------
MILAP NULL NULL 3 24
MALAY 5 6 1 12
It Helped Me So let Me share With all of you
Regards
Mrugank Dholakia
(MCA) Software Enginner
It is Very Helpful way When the no of colums are fixed which is to be converted from rows
-- Creating Test TableCREATE TABLE Product(Cust VARCHAR(25), Product VARCHAR(20), QTY INT)GO -- Inserting Data into TableINSERT INTO Product(Cust, Product, QTY) VALUES('MALAY','VEG',2)INSERT INTO Product(Cust, Product, QTY) VALUES('MALAY,'SODA',6)INSERT INTO Product(Cust, Product, QTY) VALUES('MALAY,'MILK',1)INSERT INTO Product(Cust, Product, QTY) VALUES('MALAY','BEER',12)INSERT INTO Product(Cust, Product, QTY) VALUES('MILAP','MILK',3)INSERT INTO Product(Cust, Product, QTY) VALUES('MILAP','BEER',24)INSERT INTO Product(Cust, Product, QTY) VALUES('MALAY','VEG',3)GO SELECT * FROM Product
ResultCust Product QTY
------------------------- -------------------- -----------
MALAY VEG 2
MALAY SODA 6
MALAY MILK 1
MALAY BEER 12
MILAP MILK 3
MILAP BEER 24
MALAY VEG 3
GO SELECT CUST, VEG, SODA, MILK, BEER FROM ( SELECT CUST, PRODUCT, QTY FROM Product) up PIVOT (SUM(QTY) FOR PRODUCT IN (VEG, SODA, MILK, BEER)) AS pvt ORDER BY CUSTGO
Result
CUST VEG SODA MILK BEER
--------------- -------- ----------- -------- -----------
MILAP NULL NULL 3 24
MALAY 5 6 1 12
It Helped Me So let Me share With all of you
Regards
Mrugank Dholakia
(MCA) Software Enginner
Subscribe to:
Posts (Atom)