473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

ignore single qoutes while inputing

10
hi all
i want to escape starting ('' )at the start of string
i want to just replace the string
Expand|Select|Wrap|Line Numbers
  1. <%@ WebHandler Language="C#" Class="Type_BLC"  %>
  2.  
  3. using System;
  4. using System.Web;
  5. using System.Data;
  6. using System.Data.OracleClient;
  7. using System.Web.SessionState;
  8. using System.Text;
  9. using System.Text.RegularExpressions;
  10.  
  11.  
  12.  
  13.     public class Type_BLC : IHttpHandler ,IRequiresSessionState 
  14.     {
  15.         DataAccess oraDA =new DataAccess ();
  16.  
  17.         public void ProcessRequest(HttpContext context)
  18.         {
  19.  
  20.            // string Is_ID = context.Request.QueryString["catType"];
  21.             string Is_DESC = context.Request.QueryString["CAT_DESC"];
  22.             Is_DESC = Is_DESC.Replace("'", "''");                                          
  23.             string Is_Index = context.Request.QueryString["CAT_INDEX"];
  24.             string Is_singleton = context.Request.QueryString["singleton"];
  25.             string Is_cardinality=context .Request .QueryString ["cardinality"];
  26.             string Is_node = context.Request.QueryString["IS_NODE"];
  27.             string validat = "^[YyNn]$";
  28.             string valIndex = "([a-z]|[A-Z]|[0-9]{4})";
  29.             //string valDesc = @"""[^""\\\r\n]*(?:\\.[^""\\\r\n]*)*";
  30.             string validateCardinality = "([00]|[01]|[10]|[1n]{1})";
  31.             //to validate the string
  32.             //string valDesc =@"""([^""\\]|\\['""\\0abfnrtv]|\\x[a-fA-F0-9][a-fA-F0-9]{0,3})*""";
  33.             //string valDesc = @"""([^""\\]|\\['""\\]|[a-zA-Z]|[0-9])""";
  34.             //string valDesc = "([a-zA-Z0-9]{?})";
  35.            // string valDesc = @"(?<q>[""'].*?\k<q>|w+)";
  36.             string Is_msg2 = "String is not in proper format";
  37.             //string Is_msg = "Only Y or N";
  38.             string Is_msg4 = "Only Characters";
  39.             string Is_msg1 = "Only 00 or 01 or 10 or 1n";
  40.             //if (Regex.IsMatch(Is_singleton, validat) )               
  41.  
  42.             //    context.Response.Redirect("Type_INC.aspx?msg=" + Is_msg);
  43.             //if (!(Regex.IsMatch(Is_DESC, valDesc)))
  44.             //context.Response.Redirect("Type_INC.aspx?msg2=" + Is_msg2);
  45.            if (!(Regex.IsMatch(Is_node, validat)))
  46.                 context.Response.Redirect("Type_INC.aspx?msg=" + Is_msg2);
  47.             if (!(Regex.IsMatch(Is_cardinality, validateCardinality)))
  48.                 context.Response.Redirect("Type_INC.aspx?msg1=" + Is_msg1);
  49.             if (!(Regex.IsMatch(Is_Index , valIndex )))
  50.                 context.Response.Redirect("Type_INC.aspx?msg4=" + Is_msg4);
  51.             //if (!(Regex.IsMatch(Is_DESC, valDesc)))
  52.             //    context.Response.Redirect("Type_INC.aspx?msg2=" + Is_msg2);
  53.  
  54.             //Regex customExp = new Regex(validat);
  55.             //Match m = customExp .Match (Is_singlton  );
  56.             //if (!(m.Success ))
  57.             //{
  58.             //    context.Response.Redirect("Type_INC.aspx?msg="+Is_msg2);
  59.             //}
  60.  
  61.             //if (Is_node != customExp)
  62.             //    context.Response.Redirect("Type_INC.aspx?msg="+Is_msg2);
  63.  
  64.  
  65.             //context.Response.ContentType = "text/plain";
  66.             //context.Response.Write("Hello World");
  67.             bool bFlag = false;
  68.             if (insert_Record( Is_DESC, Is_Index,Is_singleton,Is_cardinality ,Is_node))
  69.             {
  70.                 bFlag = true;
  71.             }
  72.             if(bFlag )
  73.             {
  74.  
  75.                 context.Response.Redirect("/Admin/Common/Info_MS.aspx?msg='Sucessfully Added Category Type'&LINKID=3" );
  76.                 //context.IsPostNotification = Is_msg;
  77.  
  78.             }
  79.             context.Response.Redirect("/Admin/Common/Err_MS.aspx?msg=" +oraDA.getError().Replace("\n", ""));
  80.  
  81.         }
  82.  
  83.         public bool IsReusable
  84.         {
  85.             get
  86.             {
  87.                 return false;
  88.             }
  89.  
  90.         }
  91.         //public bool InsertType(CategoryType cat)
  92.         //{
  93.         //    string oraStr = "Data Source=TESTORA;User ID=project01_user;Password=project01_user";
  94.         //    string Insert = "INSERT INTO TX_TYPE (TX_TYPE,TX_DESC)VALUES (&TX_TYPE,&TX_DESC)";
  95.         //    OracleConnection oraConn = new OracleConnection(oraStr);
  96.         //    OracleCommand oraCmd = new OracleCommand(Insert, oraConn);
  97.         //    oraCmd.CommandType = CommandType.Text;
  98.         //    try
  99.         //    {
  100.         //        oraCmd.Parameters.Add(new OracleParameter("&TX_TYPE", cat.CatType));
  101.         //        oraCmd.Parameters.Add(new OracleParameter("&TX_DESC", cat.CatDescription));
  102.         //        oraConn.Open();
  103.         //        {
  104.         //            int oraRow = oraCmd.ExecuteNonQuery();
  105.         //            if (oraRow > 0)
  106.         //                return true;
  107.         //        }
  108.  
  109.         //    }
  110.         //    catch (Exception)
  111.         //    {
  112.  
  113.         //        return false;
  114.         //    }
  115.         //    finally
  116.         //    {
  117.         //        if (oraConn.State == ConnectionState.Open)
  118.         //            oraConn.Close();
  119.         //    }
  120.  
  121.  
  122.         //    return false;
  123.         //}
  124.  
  125.        public  bool insert_Record( string Is_DESC,string Is_Index,string Is_singlton,string Is_cardinality,string Is_node)
  126.             {  
  127.  
  128.         bool bFlag = false;
  129.  
  130.  
  131.         oraDA.setConnectionString();
  132.         //oraDA.setConnectionString("Data Source=TESTORA;User ID=project01_user;Password=project01_user;");
  133.  
  134.         if (oraDA.connect2DB())
  135.         {
  136.  
  137.             //template code on how to insert or update data using transaction object
  138.             //always use this method for insert, update and delete.
  139.             //string[] sqlArr = new string[2];
  140.             string[] sqlArr = new string[1];
  141.             //sqlArr[0] = "INSERT INTO TX_TYPE (CAT_TYPE,CAT_DESC) VALUES ('95','dummy')";
  142.             //sqlArr[1] = "INSERT INTO TX_TYPE (CAT_TYPE,CAT_DESC) VALUES ('96','dummy')";
  143.  
  144.             sqlArr[0] = "insert into TX_TYPE (CAT_TYPE,CAT_DESC,CAT_INDEX,SINGLETON, CARDINALITY, IS_NODE) VALUES((select NVL(MAX(CAT_TYPE),1) + 1 from TX_TYPE),'" + Is_DESC + "','" + Is_Index + "','" + Is_singlton + "','" + Is_cardinality + "','" + Is_node + "')";
  145.             //call transaction function
  146.  
  147.             if (oraDA.transact(sqlArr))
  148.             {
  149.                 bFlag = true;
  150.             }
  151.  
  152.         }
  153.  
  154.         return bFlag;
  155.  
  156.         }
  157.  
  158.     }
is_desc staring like this ''imran
i want to insert into data base.
how is it possible
Sep 5 '08 #1
1 1318
kenobewan
4,871 Expert 4TB
If you are trying to prevent sql injections, one way is using parameters. Not sure that I understand your question or why there is alot of code included.
Sep 5 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Thomas Mlynarczyk | last post by:
Which is the simplest way to remove all whitespace from a string? Is there a simpler method than a regex replace? Or how can I tell a regex pattern to ignore all whitespace in my subject string?...
5
by: Luis | last post by:
Please help, this is due at 11:59 PM tonite. Thanks Write a program that reads a person's name from the keyboard in the format First Middle Last. It should then (1) print each of the names on...
1
by: Greg | last post by:
The following code works fine on Mozilla but generates an error* on IE, when the button calling the function is pressed and the slideshow is either on the first slide or last slide. * I can't...
4
by: DraguVaso | last post by:
hi, I'm having troubles putting a string with double qoutes (") in it in an application configuration file (App.Config). The string i need to put in it is: '/profile "MS Exchange Settings" ' ...
4
by: Greg | last post by:
I keep getting an error when I have a tick mark in a text value that I am searching for in my XPath Query. Example: <Authors> <Author LastName="O'Donnel"> <Author LastName="Smith">...
1
by: Maria | last post by:
Hello I have not used db2 in a long time, and I have this very long insert script, which is giving me an error of duplicated inserts. My question is how can I put something in the statment so...
23
by: FrancisC | last post by:
#include <stdio.h> int file_copy( char *oldname, char *newname ); int main() { char source, destination; printf("\nEnter source file: ");
9
by: Newcomer | last post by:
Hi, I added a string property for my winforms control. This string property can take multiple lines of text by using "\r\n". For example, "Hello\r\nWorld" SHOULD prints: Hello World The...
1
by: Agnes | last post by:
For single datagrid, i can bind the table very well, I can add myGridTablestyle to the datagrid. However, after i set the relations before dgParents and dgDetails. It ignore my tablestyle()....
2
by: gimme_this_gimme_that | last post by:
var a = 'what goes in here to get a single quote?';
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.