[Source code] C # To SQL translator. NET 1.1

Source: Internet
Author: User
The translator solves the problem of adding many double quotation marks from SQL to C #. Code Format and adjust. The length of each line is about 70.

Format # Region Format
Private   String Formatstring = String . Empty;
Private   Int Index =   0 ;
Private Stringbuilder sbword =   New Stringbuilder ();
Char [] Splitc =   New   Char [] {' ','\ T','\ R','\ N'} ; // ',', '= ',
Char [] Splituse =   New   Char [] {',','='} ;
Private   Bool Insplitc ( Char [] Splitc, Char C)
{
For ( Int I = 0 ; I < Splitc. length; I ++ )
{
If(C=Splitc [I])
Return True;
}
Return   False ;
}
Private   Char Peek ()
{
ReturnPeek (1);
}
Private   Char Peek ( Int I)
{
If(Index+I> =Formatstring. length)
Return '\ 0';
ReturnFormatstring [Index+1];
}
/**/ /// <Summary>
///Returns a character group, keyword, variable, or string.
/// </Summary>
/// <Returns> </returns>
Private   String Getaword ()
{
Sbword. Remove ( 0 , Sbword. Length );
Int Oldindex = Index;
Char C;
Char PC;

// Skip Blank
For (; Index < Formatstring. length; index ++ )
{
If(!Insplitc (splitc, formatstring [Index])
Break;

}


Oldindex = Index;
For (; Index < Formatstring. length; index ++ )
{
PC = Peek ();

C = Formatstring [Index];
If (Insplitc (splitc, c ))
Break ;
If (Insplitc (splituse, c ))
{
Break;
}
}

If (Oldindex < Index)
Return Formatstring. substring (oldindex, Index - Oldindex );
Else // If (oldindex = index)
{< br> If (index formatstring. length)
return formatstring [index +++ ]. tostring ();
else
return " \ n " ;
}


}
# Endregion

Download source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.