Friday, September 7, 2012

use chinese character in asp page

to save chinese character to database that already supported:

INSERT INTO dbo.YourTable(NVarcharColumn)
    VALUES(N'Some Chinese text here')

to retrieve it into asp classic page: 
Response.ContentType = "text/html"
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
Response.CodePage = 65001
Response.CharSet = "UTF-8" 

Tuesday, August 14, 2012

Safari cannot load java applet


This error appear when opening java applet in Safari, but other browsers are working fine.
"Java is Unavailable or Not Installed. Do you want to go to a page where you can download java?"

and this error message pop up:
"The Java Runtime Environment cannot be loaded from <C:\PROGRA~2\Oracle\JAVAFX~1.1RU\bin\server\jvm.dll>”

How to solve it (on Windows 7):
1. Open Regedit in this location: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Plug-in.
2. There you can find 2 folders, in my PC is was: 10.5.0 and 10.5.1
and there you can find a reference to the path "C:\\Program Files (x86)\\Oracle\\JavaFX 2.1 Runtime".
3. back up the registry by Exporting the "10.5.1" key (folder).
4. Delete that key ("10.5.1").
5. close all Safari browser, then reopen and try again.

^^v

Thursday, June 28, 2012

Clear java applet cache

Just to note how I usually clear cache for jar file, when the file replaced with the new jar file but with the same name. 






debug classic asp error 500


After changing asp file's name, then error 500 occurs, here's how to solved the problem.

Try to check in windows eventvwr, there is an error like this:
Error: The Template Persistent Cache initialization failed for Application Pool 'ASP Classic' because of the following error: Could not create a Disk Cache Sub-directory for the Application Pool. The data may have additional error codes..

Setting in your website to view detailed error:
1. Goto IIS,
2. >Default Web Site
3. >Your Virtual Directory/Website
4. Switch to Features View (if not in feature mode)
5. below IIS grouping, choose Error Pages, then double click
6. on right window, click Edit Feature Settings
7. pick Detailed errors (the second radio button)
8. click OK

Internet Explorer has a feature that blocks the true error message from being displayed. In order to display the true error message, follow the instructions below:
1.     Open Internet Explorer
2.     Go to "Tools" --> "Internet Options"
3.     Go to "Advanced" tab
4.     Uncheck "Show Friendly Error Message"
5.     Click "OK"
6.     Reload the page, you should now see a more detailed error message.
Source: http://support.discountasp.net/KB/a322/i-receive-http-500-internal-server-error-when-i-try.aspx

Then finally I found the root of the problem, it is in my asp code, I change the file name but forgot to change the name in <include> tag inside the code, lol.

Thursday, May 17, 2012

Disabled IE9 "Only secure content is displayed" pop up

To Disable/Enable/Prompt the “Only secure content is displayed” message:

  1. Start Internet Explorer.
  2. On the Tool menu, click Internet Options.
  3. Click the Security tab, and then click Custom level.
  4. In the Settings box, scroll down to the Miscellaneous section, and under Display mixed content choose from the following options:

    Disable, will not display non-secure items.
    Enable, will always display non-secure items without asking
    Prompt, will prompt you when a webpage is using non-secure content
Note: Internet Explorer 9 blocks non-secure content to keep your information safe and is set to Prompt by default. When this setting is set to Enable, Internet Explorer does not prompt you with the "Only secure content is displayed" message even if the webpage is using non-secure elements.

copy paste this from: http://support.microsoft.com/kb/2625928

Monday, May 7, 2012

UNION in SQL Server

Did you know..that..
in SQL if you UNION two queries, and if one of the table is empty, it will work as DISTINCT for the other table..?

^^v 
Julie

Monday, April 23, 2012

collation conflict in SQL


Got this error when runing a select query in Test Server, while before it was working, and it still working in my development database.

Msg 457, Level 16, State 1, Line 1
Implicit conversion of varchar value to varchar cannot be performed because the collation of the value is unresolved due to a collation conflict.

because I cannot change the structure of the database then I have to find a way so the query can be run.

this is the thing I found in the net that works without changing your database structure.

you have to find the collition conflict field, then put this line infront the field.
collate database_default

for example:
select a.field1,b.field2 collate database_default as field2alias from Dbo.table1 as a
inner join db1.dbo.tbl21 as b on b.field1 = a.field1
union all
select a.field1,b.field2 as field2alias from Dbo.table1 a
inner join db2.dbo.tbl2 as b on b.field1 = a.field1


and it works!
 -julie-

Monday, April 2, 2012

certificate problem in mozilla firefox

So I have a problem when accessing one of the server
only have this:

Technical Details
uses an invalid security certificate.
The certificate is not trusted because it is self-signed.
The certificate is only valid for
The certificate expired on 25/12/2009 12:24 PM. The current time is 3/4/2012 11:16 AM.


but don't have this:

I Understand the Risks
so cannot do the settings (cannot find either in Tools>Options)

Solutions:


try to open this site
https://www.ultimatix.net/

do the settings to the using the setting that appear when we open this site.

under I Understand the Risks
click Add Exception button.

change the location in the textbox to your destination URL, then click Get Certificate,

click Confirm Security Exception



try to open your URL once again.. :)

Friday, March 16, 2012

import failed because of FK Constraint

This is what my DBA friend told me to do:

Execute this before download data

ALTER TABLE [dbo].[TableName] NOCHECK CONSTRAINT ALL;

After downloading data remember to execute this.

ALTER TABLE [dbo].[TableName] CHECK CONSTRAINT ALL;

Hope it's useful for you also :D

Thursday, March 15, 2012

URL Rewriting in ASP.NET

will try on this when I got time :)
http://msdn.microsoft.com/en-us/library/ms972974.aspx

Tuesday, March 13, 2012

HTTP REFERER null in C#

I am trying using http referer in C# to detect another website that calls my site.

Trying but it's not working, try googling, but they all suggest using all these:

- Request.UrlReferrer
- HttpContext.Current.Request.ServerVariables["HTTP_REFERER"]

but still resulting in null.

ask my friend to try, and he succeeded.

try to check the difference in the code, and finally... got the problem...

It's not working when redirect from PAGE_LOAD because I think on page load the header is not loaded yet, so if you directly redirect the page, it will contain NULL.
He's using a button to redirect, no wonder it's working, lol

Update (20120412):
It is also not working from HTTPS to HTTP site :)

dang! a big problem for me..

Wednesday, February 15, 2012

some jquery code

jQuery(function() {

$('input#searchbox').keypress(function(event) {

if (event.keyCode == 13) {
$("#btnsearchgo").click();
}
else if (event.keyCode == 8) {
search2();
}
else {
//get text from search box + last typed letter
v = $('input#searchbox').val() + String.fromCharCode(event.charCode);

//delay the calling of the function
clearTimeout($.data(this, 'timer'));
var wait = setTimeout(search, 300);
$(this).data('timer', wait);

}

});

function search() {
var e = document.getElementById("ddlExchange");
var x = e.options[e.selectedIndex].value;

//alert(v);
$.getJSON("somecode.aspx?code=" + x + "&src=" + v,
function(data) {
//alert(JSON.stringify(data));
$('input#searchbox').jsonSuggest(data, { maxResults: 8, onSelect: callback });
}
);
}

});

isNumeric in C#

public static bool IsInteger(string theValue)
{
try
{
Convert.ToInt32(theValue);
return true;
}
catch
{
return false;
}
}

Friday, February 10, 2012

write to file asp.net c#

public void writeToFile(string msg)
{
string fileName = "tes.txt";
string appPath = HttpContext.Current.Request.ApplicationPath;
string physicalPath = HttpContext.Current.Request.MapPath(appPath);
fileName = Path.Combine(physicalPath, fileName);
StreamWriter writer = new StreamWriter(fileName);
writer.WriteLine(msg);
writer.Flush();
writer.Close();
}

Thursday, February 9, 2012

SQL Try Catch

BEGIN TRY
BEGIN TRANSACTION;
-- delete/insert statement here
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK;
-- Raise an error with the details of the exception
DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int;
SELECT @ErrMsg = ERROR_MESSAGE(),
@ErrSeverity = ERROR_SEVERITY();
RAISERROR(@ErrMsg, @ErrSeverity, 1);
END CATCH;

Tuesday, February 7, 2012

Primary Key in SQL for existing table

add primary key using query

ALTER TABLE dbo.tablename
ADD PRIMARY KEY (columname)

remove primary key using query

ALTER TABLE Table1
DROP CONSTRAINT [PK_Table1_Col1]

Tuesday, January 17, 2012

javascript function to get query string

function getQuerystring(key, default_) {
if (default_ == null) default_ = "";
key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
var qs = regex.exec(window.location.href);
if (qs == null)
return default_;
else
return qs[1];
}


source: http://www.bloggingdeveloper.com/post/JavaScript-QueryString-ParseGet-QueryString-with-Client-Side-JavaScript.aspx


^^v
julie

Monday, January 9, 2012

XML Parsing Error: not well-formed

got this error:

XML Parsing Error: not well-formed

find the answer here:
http://forums.asp.net/t/1353799.aspx/1

it says, that the problem maybe in the iis, try to re register the .net framework using this command line:
aspnet_regiis - i