Tuesday, May 10, 2011

Object Name is Not Declared

Error BC30451: Object_name is not declared
An object, e.g. button, linkbutton, or lable is created on the .aspx page. The intellisense does detect the object name. However, when it is debugged, it gives the error Object_name is not declared, where Object_name is the name of the object.

Solution:
1. If you are web application project, try deleting the aspx.cs or aspx.vb (code) file, then right-click the .aspx file, and choose Convert to web application.

2. Check if there is another copy of the same files in the same folder. This happens to me quite some times. Before doing major changes, I usually make a copy of the files first. The files are usually automatically included in the solution we are developing. Since the class of the copies have the same names, they conflict each other. Move the copy from the folder or simply exclude the copies from the solution by right-clicking on the files, then choose "Exclude From Project". See if it solves the issue.

3. If neither solution 1 nor 2 solves the issue, try adding new files with different names, then copy the content of the old files to the new ones. Note that the names of the class can not be the same. Try compiling and see if it works. If it does, you can then delete or move the old files, then rename the new files according to the old ones.

4. If none of the alternatives above work, try finding from internet, then POST IT HERE! Thanks ^_^
Share:

Thursday, May 5, 2011

Paging in SQL 2

Regarding my post about Paging in SQL, I have found another easier way to include a column as a running number of the records. Hence, we do not need to create a temporary table, and the code will be much simpler.

I will use the same tables for example. In case you find difficulty finding the post about Paging in SQL, I include them here.

Here is the Create table Query:
CREATE TABLE dbo.MsUser
(  UserID CHAR(20) PRIMARY KEY,
   Username VARCHAR(100),
   Address VARCHAR(50),
   DivisionID INT
)

And here is the query to insert sample data:
-- Insert Data into MsUser
INSERT INTO dbo.MsUser VALUES ( 'Himura', 'Miss Himura', 'Earth', 3 )
INSERT INTO dbo.MsUser VALUES ( 'Selvia', 'Selvia', 'Indonesia', 2 )
INSERT INTO dbo.MsUser VALUES ( 'Superman', 'Clark Kent', 'Earth', 2 )
INSERT INTO dbo.MsUser VALUES ( 'SelviaHimura', 'Selvia Himura', 'Earth', 4 )
INSERT INTO dbo.MsUser VALUES ( 'Luck', 'Steven Luck', 'Indonesia', 1 )
INSERT INTO dbo.MsUser VALUES ( 'SuperLuck', 'Super Luck', 'United States', 1 )
INSERT INTO dbo.MsUser VALUES ( 'Selvi', 'Selvi', 'Indonesia', 1 )
INSERT INTO dbo.MsUser VALUES ( 'Lucky', 'Lucky Luke', 'United States', 3 )
INSERT INTO dbo.MsUser VALUES ( 'Steven', 'Steven', 'Earth', 4 )

Here is the data inserted to the tables:

Here is the query to get the data using paging:
DECLARE @PageSize INT, @PageNo INT
SELECT a.Username FROM (
    SELECT Username, RowNumber = ROW_NUMBER() OVER (ORDER BY Username) 
    FROM MsUser
) a WHERE a.RowNumber BETWEEN (@PageNo - 1 )* @PageSize + 1 AND @PageNo * @PageSize

Note that the key is in this part of code:

ROW_NUMBER() OVER (ORDER BY Username)


If the PageSize is set to 5 item per page, then the top 5 users will be displayed on Page 1 and the next 5 users will be displayed on Page 2.

e.g. 1
PageSize = 5, PageNo = 1
DECLARE @PageSize INT, @PageNo INT
SELECT  @PageSize = 5, @PageNo = 1
SELECT a.Username FROM (
    SELECT Username, RowNumber = ROW_NUMBER() OVER (ORDER BY Username) 
    FROM MsUser
) a WHERE a.RowNumber BETWEEN (@PageNo - 1 )* @PageSize + 1 AND @PageNo * @PageSize

The data retrieved on Page 1 will be:

e.g. 2
PageSize = 5, PageNo = 2
DECLARE @PageSize INT, @PageNo INT
SELECT  @PageSize = 5, @PageNo = 2
SELECT a.Username FROM (
    SELECT Username, RowNumber = ROW_NUMBER() OVER (ORDER BY Username) 
    FROM MsUser
) a WHERE a.RowNumber BETWEEN (@PageNo - 1 )* @PageSize + 1 AND @PageNo * @PageSize

And the data retrieved on Page 2 will be:

Share:

Thursday, April 14, 2011

Root Element is MIssing

Error:
System.Xml.XmlException: Root element is missing.
Solution:
If you are using Web Service, check if the URL of the web service is properly set.
For example:
The URL for the web service is
http://localhost:8081/WebName/WebService.asmx

The error occurs when the URL used is, for instance:
http://localhost:8081/WebName
Share:

Monday, April 11, 2011

Compiling Assembly using TASM in Textpad

Continuing my last post about compiling and running assembly file, it is actually possible to easier compile and run assembly file from Textpad (unfortunately, you have to search for the Textpad text editor yourself :), and I think it is not hard to find it ;)).

Still, I am using TASM20 to compile and run the assembly file.
Assumption: The Tasm.exe & Tlink.exe files used to compile assembly file are located at C:\tasm20\TASM.

Here are the steps:
1. Create an assembly file on the same folder. The following coba.asm file is used to print character 'A'. The file can be created using any text editor.


2. Open Textpad, Go to menu Configure -> Preferences.


3. Choose Tools, then click Add.



4. Click Add -> Program -> browse for TASM.exe.


5. Click Add -> Program -> browse for TLINK.exe.

6. Click Add -> DOS Command -> type "cmd" (without quotes).


7. Notice that the added Programs and Dos command are now available in the middle listbox. Click Apply.


8. Expand Tools -> click on Tasm -> change the Parameters: $basename.


9. Click on Tlink -> change the Parameters: $basename /t.


10. Click on cmd -> change the Parameters: $basename, then click OK.


11. You will notice that the commands to compile and run the assembly file are now available on the menu Tools.


12. Open the assembly file coba.asm created on step 1.

13. To compile and run the program, press ctrl + 1, ctrl + 2, and ctrl + 3 respectively on the .asm file window.

14. After executing ctrl + 1 on the .asm file window, the result will be shown in Command Results window.


15.After executing ctrl + 2 on the .asm file window, the result will be shown in Command Results window.


16. To see the result, execute ctrl + 3 on the .asm file window. The result will be shown in Command Results window.


17. We are now done with the result of the assembly code :D
Share:

Compiling Assembly using TASM in command prompt

Are you learning Assembly language, and confused about how to compile assembly file?
TASM20 is one of assembly compilers that works with Windows XP and Windows 2000 operating system. However, it does not work with Windows 7 64-bit operating system.
If you are using Windows XP or Windows 2000, you can try the following steps to compile and run assembly file.
To download TASM20, the compiler used for assembly file, click here.

Assumption: The Tasm.exe & Tlink.exe files used to compile assembly file are located at C:\tasm20\TASM.

1. Open command prompt by pressing Windows + R, or go to Start menu -> Run, then type "cmd" (without quotes).

2. Go to the folder where the Tasm.exe & Tlink.exe files used to compile assembly file are located, i.e. C:\tasm20\TASM.
cd\tasm20\tasm
 

3. For instance, we have made an assembly file named coba.asm used to print character 'A' as following:

4. Commands used:
- To compile the assembly file, use command:
tasm <asm_filename>.asm
e.g.
tasm coba.asm

After executing the command above, an object file (coba.asm) will be created.

- To create .COM file, use command:
tlink /t <obj_filename>.obj
e.g.
tlink /t coba.obj

- To run the result (.COM file), use command:
<com_filename>
e.g.
coba

5. That's all, folks :)
Share:

Friday, March 18, 2011

Object tag not recognized inside form tag

Problem: When developing a page in ASP.NET, an object tag (<object>) is not recognized when it is placed in an HTML form tag (<form>).

e.g.
<html>
<head>
   <script type="text/javascript" language="javascript">
    function readScript()
    {
        Card.Connect();
    }
   </script>
</head>


 <body color=white>
    <form name="frmRead" id="frmRead">
        <object id="Card" name="Card" classid="abcDll.dll#abcDll.Card" style="display:none" ></object>
        <input type=button value="Read Card" onClick="readScript();"></td>
    </form>
 </body>
</html>

Solution: Inside the <form> tag, <object> element is out of scope. Instead of directly calling the id of the object, get the id using javascript.
function readScript()
    {
        var cardObj = document.getElementById("Card");
        cardObj.Connect();
    }

Special thanks to StackOverFlow :D
Share:

Wednesday, March 16, 2011

Cannot Run Web Application

Problem: ASP.NET web application can not be run.
Error: WebDev.WebServer.exe has encountered a user-defined breakpoint.


Solution:
The web application you are developing is using Visual Studio development server with dynamic ports. At the same time, you have the same or another web created and running under the same port in IIS.
1. Either stop the IIS for the web which is using the same port as the web application you are going to run under visual studio development server.
2. Or, change the port number of the web application running under visual studio development server. To do this, click on the website, then change the port number in the Properties Window.

Share:

Running ActiveXObject from Javascript

Problem: Can't run ActiveXObject from Javascript
Error: System.Security.Permissions.SecurityPermission

This error occurs when you are trying to run ActiveXObject / dll using Javascript.


Solution:
A. Setting the security for the internet browser, i.e. Internet Explorer
1. Using Internet Explorer, set the security to low: Goto menu Tools -> Internet Options.
2. Goto tab Security.
* Under Internet zone, set security level to Low. Click Custom level button, in ActiveX controls and plug-ins section, Enable Script ActiveX controls marked safe for scripting*, then click OK.



* Under Local intranet zone, click Custom level button, enable things under ActiveX controls and plug-ins section, and the most important one, Enable Script ActiveX controls marked safe for scripting*, then click OK.



B. Setting .Net Framework 2 Configuration
1. Make sure you have .Net Framework 2 SDK installed on your computer. You may want to install it if you have not had it installed on your computer.
2. Goto control panel -> Administrative Tools -> open Microsoft .NET Framework 2.0 Configuration.
3. On the Tasks, click Configure Code Access Security Policy -> Adjust Zone Security -> Make changes to this computer, and Next. Set My computer & Local Intranet to Full trust, then Next -> Finish.




Restart the Internet Explorer, then try running the Web page again.

PS: While it is not recommended to run untrusted ActiveX Object, because it may cause security leak; this is a workaround to solve the problem in case it is necessary to run the ActiveX Object on client side.
Share:

You may be intersted in

Related Posts

Updating Table Containing Xml Column via LinkedServer

If you are trying to update a table containing XML column via Linked Server in SQL Server, and you are not able to, you are not alone. There...

About Me

My photo
Is an ordinary man, with a little knowledge to share and high dreams to achieve. I'd be glad if I can help others, 'coz the only thing for the triumph of evil is for a good man to do nothing.

About Blog

You can find a lot of debugging and deploying problems while developing applications in .NET and Visual Basic here. There are also some querying tips in SQL and typical source codes which might be useful shared here.

Popular Posts

Blogroll

Followers

Leave a Message