Menu

 

Sunday, March 8, 2009

Use Paramaterized Query in Classic Asp

Hi,

Few days I Faced Poblem Regarding Parmaterized Query in Classic Asp...

After Some Few Hours Of Work I have Completed That Work Show I will Show very Simple
Implementaion of My work..


What I have used...

IIS6.0
Vbscripting
and XP machince



What is Requirement

It will prevent The Sql Injection..



Know I Provide With Simple Sample With Open Query..

'Sql server Connectiion String
Conn="Provider=SQLOLEDB;User ID=sa;password=a;Initial Catalog=northwind;Data Source=Avinash"

Const adCmdText = 1



Dim cmd2
Set cmd2 = Server.CreateObject("ADODB.Command")
cmd2.ActiveConnection = Conn
cmd2.CommandText = "SELECT * FROM Categories WHERE CategoryID = ? "
cmd2.CommandType = adCmdText
cmd2.Parameters(0).Value = count1
' cmd2.Parameters(2).Value = Request.Form("password")
Set rstLogin = cmd2.Execute

Response.Write("Data Came From "& aFixed(i) & " == " & rstLogin(1) & "
")

Hope This Help Some One..

Saturday, March 7, 2009

Creating COM From Csharp and VB.net

Hi,

Recently I have Create COM Object Using Dotnet ...
Know I will Show U Step By Step How Create Com Object...

I am Using Vs2008 This can follwed in Vs2005,Vs2003
I will Create "Hello Word Kind of Project"

Let Start...

1} Create Simple Dll Project From Dotnet
















2} Know Writing Function To Show On
Classic Asp page
















3} Know Creating Class COM Object
COM Visible
















4}Know Creating Strong Key
Name For COM















5} Know Adding Strong Key
To Dll

















6} Know Adding Your Dll For
Classic Asp


Regasm \codebase is Command Used for Registering
Your Dll For Classic Asp















Once You Have Registered Your Dll Know Restart
Your IIS
(It is Reqirment for Refesing COM Object")

7) Know Adding Dll To GAC
















8} Know Adding Asp Code


set OInstr = Server.CreateObject("AspCom.HelloWorld")
str_msg = OInstr.strMYname("Avinash") Response.Write(str_msg)
'How to Acess Other Class Ib COM Object
str_msgMe = Ostr.MessageFromSecondClass("Avinash") Response.Write(str_msgMe)


9}Code OF Csharp Main Code :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AspCom
{
public class HelloWorld
{
public string strMYname(string strName)
{
string straMyname = "";

straMyname = "Hello World I Came From Csharp=" + strName;
return straMyname;
}
public string MessageFromSecondClass(string str_message)
{
string str_mess = "";
test testme = new test();
str_mess = testme.TestSecondClass(str_message);

return str_mess;
}
}
}

10} Test Class Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AspCom
{
class test
{
public string TestSecondClass(string strMsg)
{
string strName = "";
strName = "Hello I am From Second Class" + strMsg;
return strName;
}
}
}



11} Know UnRegistrating The Dll
















12} Know Unstialling From GacUtil















<
14} How To Acess The Database In Com..
If Looop Data in Recordset Then pass in form of XML...
U want Insert,Update or Delete Data From database
U have Pass Parameter as U passwed Hello world Project
and create Login of Add Modif Or delete as U do normally in
Dotnet.
Page..
Pass The parameter and Manuplate as U want..

Hope It Help Some Body



Keyset_not_Found_Or_Acess_Denied

Hi,

After Long Long Research(not so Long only Few Days) I Found answer for KEYSET NOT FOUND AND ACESS DENINED(classic Asp and Asp.net Certificate Cryptographic) While Using CryptoCraphic With Certificates...

So Let Start The Solution

First We will Understand The Key Concept of .pfx File or Certificate File

Private Keys live in a File-Based Protected Store,
Certificates live in a Registry-Based Certificate Store


When certificate w/ private keys are installed from a .pfx file, the certs are installed in a registry-based certificate store, but the private keys are installed in a "protected store".

Each user account on a Windows system has it’s own certificate store (in the HKEY_CURRENT_USER branch). There is also a machine-wide certificate store in the HKEY_LOCAL_MACHINE registry branch. A cert can be installed to either one (or both).

If the cert is installed interactively via the certmgr.msc certificate management console into the HKEY_CURRENT_USER, the ASP IUSR process won’t find it.

Likewise, each user account on a Windows system has it’s own "protected store". (For those interested in more information about protected stores, Google "DPAPI" and you’ll find lots of info…) There is also a machine-wide "protected store".

If you import a .pfx interactively such that the private keys are saved to your interactive account’s "protected store", then they will not be accessible to ASP / ASP.NET, which is running in an IUSR account.

Know we Start Importing The .pfx File

You’ll import the PFX by using the Certificate Management Console, but for the
Local Machine, not for your current logged-on user account. Follow these
instructions to start the MMC for the local machine cert store:

1. Log on to the system as an administrator.

Know Once U have Logged

2. Click Start, click Run, type mmc, and then click OK.











3. On the File menu, click Add/Remove Snap-in, and then click Add.

























4. Under Snap-in, double-click Certificates, click Computer account, and then click Next.















5. Do one of the following:

6. To manage certificates for the local computer, click Local computer, and then click Finish.

7. To manage certificates for a remote computer, click Another computer and type

the name of the computer, or click Browse to select the computer name, and then click Finish.

8. Click Close. Certificates (Computer Name) appears on the list of selected snap-ins

for the new console.

Once U have Complete Above Step U will Find The Follwing Image..















9. If you have no more snap-ins to add to the console, click OK.














 10. To save this console, on the File menu, click Save.

Begin the PFX Import:

1) Right-click on the Personal folder, located under "Certificates (Local Computer)",
and select All Tasks –> Import.











2) Click Next, browse to your .pfx file and select it. Make sure the "Files of type" dropdown is set to "*.pfx; *.p12;" so you can see the .pfx files. Click Next. Enter the password for your .pfx file. (I always mark the key as exportable.) Click Next. Use the "Personal" certificate store, which is the default and already selected. Click Next. Click Finish. That’s it.

Know You Finised Installation Of Certificate Know We Will Move To Step2 To Get Rid Of This
Irrating Error
1) Open Windows Explorer and navigate to the directory where the keys are located: C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys

2) Make sure you’re not using the "Simple File Sharing" mode in Windows Explorer. In the Windows Explorer Tools menu, select "Folder Options". Then select the "View" tab. Scroll down and make sure the "Use simple file sharing" checkbox is unchecked.















4) Right-click on the MachineKeys folder.
Select "Properties", then select the "Security" tab. (Note: If you didn’t turn off simple file sharing, you wouldn’t see the "security" tab.)

5) You’re going to add your IUSR_**** account and give it full permission. Click the "Add.." button. Type your IUSR account name and click "Check Names". Then click "OK".

6) The IUSR account is now listed. Select it and then check the "Full Control" checkbox (causing all the other Allow checkboxes to be selected). Then click "Apply".

You’ve done it. Now you can use that cert w/ private key in ASP or ASP.NET. You can also use any other certs imported into the Local Machine/Personal certificate store.

Know The error Which Occurs from Will We Not Here..

Hope This Blog Help Bugger Like Me How JUST KNOW WHO TO USE SERACH ENGININE FIND SOLUTION...

All Menu