Click here to Skip to main content
15,896,063 members
Home / Discussions / C#
   

C#

 
AnswerRe: transfer files from aclient to another using socket programming+c#? Pin
stancrm19-Oct-09 6:13
stancrm19-Oct-09 6:13 
QuestionReading Data from a CD Pin
AndyASPVB19-Oct-09 5:28
AndyASPVB19-Oct-09 5:28 
AnswerRe: Reading Data from a CD Pin
stancrm19-Oct-09 6:12
stancrm19-Oct-09 6:12 
GeneralRe: Reading Data from a CD Pin
AndyASPVB19-Oct-09 8:44
AndyASPVB19-Oct-09 8:44 
GeneralRe: Reading Data from a CD Pin
Richard MacCutchan19-Oct-09 8:57
mveRichard MacCutchan19-Oct-09 8:57 
QuestionFormat SQL statement into C# string. Pin
RK KL19-Oct-09 5:15
RK KL19-Oct-09 5:15 
AnswerRe: Format SQL statement into C# string. Pin
Not Active19-Oct-09 5:51
mentorNot Active19-Oct-09 5:51 
GeneralRe: Format SQL statement into C# string. Pin
RK KL19-Oct-09 6:01
RK KL19-Oct-09 6:01 
Hmm... haven't heard that before, but I'll give it a try... Poke tongue | ;-P

I was referencing converting a SQL statement to C# string...

But, here's what I came up with in case someone needs this... Assign this macro a short cut of of Ctl+Shift+F3

It converts
select *
From Status
From ActivityStatus ActStsId=StsId

to
string sql = "   	    select * "+
"	    From Status "+
"	    From ActivityStatus ActStsId=StsId";


Macro is as follows.
Sub SQL2CSharp()
    Dim selection As EnvDTE.TextSelection
    Dim startPoint As EnvDTE.EditPoint
    Dim endPoint As TextPoint
    Dim quoteStart As String

    selection = DTE.ActiveDocument.Selection()
    startPoint = selection.TopPoint.CreateEditPoint()
    endPoint = selection.BottomPoint
    quoteStart = """"

    DTE.UndoContext.Open("SQL 2 CSharp")
    Try
        startPoint.Insert("string sql = """)

        Do While (True)
            Dim line As Integer

            line = startPoint.Line
            startPoint.Insert(quoteStart)
            startPoint.EndOfLine()
            If (line = endPoint.Line) Then
                startPoint.Insert(quoteStart & ";")
            Else
                startPoint.Insert(quoteStart & "+")
            End If
            startPoint.LineDown()
            startPoint.StartOfLine()
            If (line = endPoint.Line) Then
                Exit Do
            End If
        Loop
    Finally
        ' If an error occurred, then make sure that the undo context is cleaned up.
        ' Otherwise, the editor can be left in a perpetual undo context.
        DTE.UndoContext.Close()
    End Try
End Sub


You can never try. You either do it or you don't.

GeneralRe: Format SQL statement into C# string. Pin
Not Active19-Oct-09 6:17
mentorNot Active19-Oct-09 6:17 
GeneralRe: Format SQL statement into C# string. Pin
RK KL19-Oct-09 7:01
RK KL19-Oct-09 7:01 
GeneralRe: Format SQL statement into C# string. Pin
Not Active19-Oct-09 7:19
mentorNot Active19-Oct-09 7:19 
GeneralRe: Format SQL statement into C# string. Pin
EliottA19-Oct-09 8:17
EliottA19-Oct-09 8:17 
GeneralRe: Format SQL statement into C# string. Pin
RK KL19-Oct-09 9:06
RK KL19-Oct-09 9:06 
GeneralRe: Format SQL statement into C# string. Pin
Not Active19-Oct-09 9:19
mentorNot Active19-Oct-09 9:19 
GeneralRe: Format SQL statement into C# string. Pin
RK KL19-Oct-09 9:25
RK KL19-Oct-09 9:25 
GeneralRe: Format SQL statement into C# string. Pin
Not Active19-Oct-09 9:58
mentorNot Active19-Oct-09 9:58 
GeneralRe: Format SQL statement into C# string. Pin
RK KL19-Oct-09 10:13
RK KL19-Oct-09 10:13 
GeneralRe: Format SQL statement into C# string. Pin
Brady Kelly19-Oct-09 11:21
Brady Kelly19-Oct-09 11:21 
GeneralRe: Format SQL statement into C# string. Pin
Not Active19-Oct-09 11:51
mentorNot Active19-Oct-09 11:51 
GeneralRe: Format SQL statement into C# string. Pin
PIEBALDconsult19-Oct-09 15:37
mvePIEBALDconsult19-Oct-09 15:37 
AnswerRe: Format SQL statement into C# string. PinPopular
AspDotNetDev19-Oct-09 10:25
protectorAspDotNetDev19-Oct-09 10:25 
GeneralRe: Format SQL statement into C# string. Pin
Mycroft Holmes19-Oct-09 12:23
professionalMycroft Holmes19-Oct-09 12:23 
QuestionA problem with namespace? Pin
George Quarton19-Oct-09 5:15
George Quarton19-Oct-09 5:15 
AnswerRe: A problem with namespace? Pin
Luc Pattyn19-Oct-09 6:12
sitebuilderLuc Pattyn19-Oct-09 6:12 
GeneralRe: A problem with namespace? Pin
George Quarton19-Oct-09 6:31
George Quarton19-Oct-09 6:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.