Monday, May 25, 2009
Whitespace is not allowed at this location.
i came across an error on an XMl that reads
XML comment contains invalid XML: Whitespace is not allowed at this location".
This is because in your Column fields that you pass to the Xml there is ampresant and in XML its a special character, now you need to turn it off. well in my case and your case its simple , you need to leave your code the way it and in your code where you pass the xml string, you must use the replace function in C# or Vb.net like this
Xml.Replace("&", "& amp;");
the "&" will turn it off and everything will be good again.
Thank you
Vuyiswa Maseko
Wednesday, May 6, 2009
How to Remove Duplicates in a string in SQL
Here is How it was done,
Create a UDF(User Derfined Function)
alter FUNCTION dbo.DistinctList
(
@List VARCHAR(MAX),
@Delim CHAR
)
RETURNS
VARCHAR(MAX)
AS
BEGIN
DECLARE @ParsedList TABLE
(
Item VARCHAR(MAX)
)
DECLARE @list1 VARCHAR(MAX), @Pos INT, @rList VARCHAR(MAX)
SET @list = LTRIM(RTRIM(@list)) + @Delim
SET @pos = CHARINDEX(@delim, @list, 1)
WHILE @pos > 0
BEGIN
SET @list1 = LTRIM(RTRIM(LEFT(@list, @pos - 1)))
IF @list1 <> ''
INSERT INTO @ParsedList VALUES (CAST(@list1 AS VARCHAR(MAX)))
SET @list = SUBSTRING(@list, @pos+1, LEN(@list))
SET @pos = CHARINDEX(@delim, @list, 1)
END
SELECT @rlist = COALESCE(@rlist+',','') + item
FROM (SELECT DISTINCT Item FROM @ParsedList) t
RETURN @rlist
END
And Run your Fuction like this
SELECT dbo.DistinctList(MY_FIELD,' ') DistinctList FROM MYTABLE
This Function takes two parameters the first one is the duplicated string, in this case i have used my field in mytable. e.g if you have
"12345612345" and run this on your field ,you will end up with
"123456"
Thanks
Vuyiswa Maseko
Wednesday, April 29, 2009
How to Show a Mesage Box in ASP.NET
MessageBox.Show("Your Message here...");
This can still be used in the Web but , your message box will show at the taskbar and this will not be your intentions. To over come this in Asp.net you have to create a Function like this
public void CreateMessageAlert(System.Web.UI.Page aspxPage, string strMessage, string strKey)
{
string strScript = "";
if (!ClientScript.IsStartupScriptRegistered(strKey))
{
ClientScript.RegisterStartupScript(typeof(Page), strKey, strScript);
}
}
and you can call it like this
string strMessage = "You Message here...";
CreateMessageAlert(this.Page, strMessage, "strKey1");
That is Simple.
Vuyiswa Maseko
Tuesday, April 28, 2009
The State Information is Invalid for this Page and might be Corrupted
Problem:
This comes, because from version 2.2.2, we made the RadUploadHttpModule parse the files when used with the Cassini web server. I believe you have encountered a similar problem - the request data is not read properly by the RadUploadHttpModule and corrupt ViewState data is passed to the page. and you finnaly get the error
The case-sensitive value that the TemplateSourceDirectory property of a page returns is used to create and to validate the ViewState property for that page. The value of this property for a page depends on the case-sensitive URL that the first user for that page requested. This value is reused for the remaining requests for that page until that page is recompiled. When the page is recompiled, the TemplateSourceDirectory property is re-initialized. If the new value (which is case-sensitive) differs from the previous value, the ViewState validation from the existing clients fails.
The State Information is Invalid for this Page and might be Corrupted
Resolutions:
- Someone else reported the same error and seemed to have found a workaround by causing his upload button PostbackUrl to go to the same page like this
btnAddFile.PostBackUrl = "~/NewsAddFiles.aspx?NewsId=" + hiddenNewsId.Value;
2. Download a hotFix http://support.microsoft.com/default.aspx?scid=kb;ko;323744
http://support.microsoft.com/ph/1173#tab0
3: Save the radion button selection and tree control node selection in session variables instead of view state, because the life scope of the view state is only within the page. When user navigates away to a different page, the view state of the previous page is destroyed.
Hope this This Helps
Vuyiswa Maseko
Tuesday, March 24, 2009
Cannot Find keycodev2.dll or invalid keycode
Solution:
- Deploy the application including the mergemodules:
Crystal_Database_Access2003.msm (necessary if you use ado)
Crystal_Database_Access2003_enu.ms m (necessary if you use ado)
Crystal_Managed2003.msm
Crystal_regwiz2003.msm (don't forget to set license key in properties)
VC_User_CRT71_RTL_X86_---.msm
VC_User_MFC71_RTL_X86_---.msm
http://support.businessobj
http://support.businessobj
http://support.businessobj
Thank you
Vuyiswa Maseko
Cannot Create Windows Folder Named Con
It is true that you cannot create a folder with the Following names
- PRN
- AUX
- NUL
- LPT1
- COM1
- Potential drive letter - A: to Z:
- A number of others
Microsoft MS-DOS reserves certain names for system device drivers. If you try to name a file using one of these names, you will receive the following error message:
Write Fault Error Writing Device
Abort, Retry, Ignore, Fail?
The solution is to change the file name.
Below is a list of default device driver names.
Name Function
---- --------
CON Keyboard and display
PRN System list device, usually a parallel port
AUX Auxiliary device, usually a serial port
CLOCK$ System real-time clock
NUL Bit-bucket device
A:-Z: Drive letters
COM1 First serial communications port
LPT1 First parallel printer port
LPT2 Second parallel printer port
LPT3 Third parallel printer port
COM2 Second serial communications port
COM3 Third serial communications port
COM4 Fourth serial communications port
- mem /d more
- debug d 0070:0000
APPLIES TO
- Microsoft MS-DOS 2.11 Standard Edition
- Microsoft MS-DOS 3.1
- Microsoft MS-DOS 3.2 Standard Edition
- Microsoft MS-DOS 3.21 Standard Edition
- Microsoft MS-DOS 3.3 Standard Edition
- Microsoft MS-DOS 3.3a
- Microsoft MS-DOS 4.0 Standard Edition
- Microsoft MS-DOS 4.01 Standard Edition
- Microsoft MS-DOS 5.0 Standard Edition
- Microsoft MS-DOS 5.0a
- Microsoft MS-DOS 6.0 Standard Edition
- Microsoft MS-DOS 6.2 Standard Edition
- Microsoft MS-DOS 6.21 Standard Edition
- Microsoft MS-DOS 6.22 Standard Edition
Thank you
Vuyiswa Maseko
Tuesday, March 17, 2009
Could not load file or assembly 'App_Code' or one of its dependencies. There is not enough space on the disk. (Exception from HRESULT: 0x80070070)new
Could not load file or assembly 'App_Code' or one of its dependencies। There is not enough space on the disk. (Exception from HRESULT: 0x80070070)
दो नोट पनिक, थिस इस नोट अ प्रॉब्लम इन यौर ऍप्लिकेशन और यौर कोड, बुत इट्स अ प्रॉब्लम ओं यौर सर्वर।। तेरे अरे प्लेंटी ऑफ़ रेसोलुशन तो थिस प्रॉब्लम ,
1) रन थे डिस्क क्लेअनुप तो रेमोवे उनुसेद और टेम्प फिल्स एंड रिस्टार्ट यौर सर्वर अनडी विल सोल्वे यौर प्रॉब्लम
२)That's pretty clearly a disk space error। While your account may have plenty of disk space available, the error might refer to the operating system partition on the machine - since the error occurs when assemblies are being loaded into memory which likely will occur on the OS disk. Your Web space is probably on a different partition than the OS, and there is probably plenty of space there.
ठनक you
Monday, March 16, 2009
How to Get the Selected Item in a ListBox Control(ASP.NET 2.0,3.5 C#)
String myselecteditem = listBox1.SelectedItems;
And you can do the same thing with a Dropdownlist
String mydropdownlist = dropdownlist1.SelectedItems;
Now all this will return what a user see on the List box, if it’s a list of numbers like {1,2,3,4,5} then the value that will be contained in there is that.
Thanks
Friday, March 13, 2009
Buiding N-Tier VS NON N-Tier Applications
There different ways to do things, I don’t expect a programmer before me to do things the way I do them or the programmer after me to do the things the way I do them. But I believe companies should enforce a law on the approach of application development. If programmers were arrested for doing certain things in an application, I think a lot would have been arrested and that includes me.
I came to learn from my first article i wrote for codeproject . That application should be tired. No matter how small the application can be they should be tired. I came across applications that were poorly tired, at least they tried and I can across the applications that were not tired at all. Coming from an n-tier background has become worse part of my career finding that an enterprise application has not been tired. In some instances you will find form with sql inside, in others you will find pages with sql inside them. Microsoft has made programmers of today more productive and programmers abused their powers, today data layers are not created anymore, not to mention business logic layer. People write code that is a victim to sql injection . I have just enjoyed the benefits of writing applications in an n-tier style.
ü It’s easy to maintain the application. If there is an exception, you know which part to check.
ü It has resilience to change, if a new functionality is requested, you will not touch other part of the code, you will just add in 3 places your DAL (Data Access Layer) àBLL (Business Logic Layer) àPL (Presentation Layer).
ü Your layer can be access by any type of Client WEB ,Windows or Mobile
ü A Programmer After you will follow the same Rules and he will understand the System very easily.
ü The SQL side is done only on the SQL server and the StoredProcedure are called from one layer (DAL).
ü Errors are handled in one place, which mean in a DAL errors are not handled, but instead they are passed to the calling function or method.
ü Business Rules are not handled in the Pages or Forms; they are handled in the BLL layer.
Microsoft has done a very good job on its technologies like ado.net and more… When Linq was introduced, it did not fit into my plans; I kept my sql in the Server and continued to call my sp’s from the data access layer. Now Linq to dying see below links
http://ayende.com/Blog/archive/2008/10/31/microsoft-kills-linq-to-sql.aspx
http://quintesvanaswegen.com/2009/01/15/on-net-microsoft-kills-linq-to-sql/
, I don’t know what is going to happen to those who implemented it. This proved that it is not a good idea to write your sql with your C# or vb.net code. In this Blog I welcome critics and good comments. Tell me what you think about this subject.
Thank you,
Solution:
1 - Go to the folder containing the solution files and delete the following: mssccprj.scc
MyProject.vssscc
vssver.scc
2 - Open MyProject.sln in your favorite text editor and remove the following section:
GlobalSection(SourceCodeControl) = preSolution ... EndGlobalSection
3 - Go to the folder containing the project files and delete the following: MyProject.vbproj.vspscc
mssccprj.scc
vssver.scc
4 - Open MyProject.vbproj in your text editor and remove the following lines:
SccProjectName = "SAK"
SccLocalPath = "SAK"
SccAuxPath = "SAK"
SccProvider = "SAK"
Now you can open the solution/project with no source control errors.
Thank you