[RESOLVED] How to split the Lengthy Insert Command Line Text Line ?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: [RESOLVED] How to split the Lengthy Insert Command Line Text Line ?

  1. #1
    Join Date
    Dec 2011
    Posts
    53

    [RESOLVED] How to split the Lengthy Insert Command Line Text Line ?

    Hi, I have table around 90 Columns. Now my problem is when I wish to use the Insert Command
    it's not executing... The reason is that the command is very lengthy... So how to split the line ?

    My Command

    SqlCommand^ DetailedInsert = gcnew SqlCommand("Insert into Table1 (col1,col2,col3,...col90) values (val1,val2,val3,...val90)", SqlCon);

    DetailedInsert->ExecuteNonQuery();

    So that DetailedInsert Command Text is very lengthy, How to split that line as like c#?

    Thanks

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,585

    Re: How to split the Lengthy Insert Command Line Text Line ?

    I don't know how that's done in C#, but C++ (/CLI as well as native) interprets adjacent string literals separated by nothing but whitespace as a single string literal. That is, "x" "y" is equivalent to "xy". And as line breaks count as whitespace, this can be used to split long string literals across multiple source code lines, like this:

    Code:
    SqlCommand^ DetailedInsert = gcnew SqlCommand("Insert into Table1 (col1,col2,col3,...col90) "
      "values (val1,val2,val3,...val90)", SqlCon);
    However, C++ doesn't impose any limitation on the length of source code lines; they're just pretty annoying when editing the code. So if anything actually prevents your SQL command from executing properly, I suspect there's yet another problem.
    Last edited by Eri523; November 21st, 2013 at 11:10 AM.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Dec 2011
    Posts
    53

    Re: How to split the Lengthy Insert Command Line Text Line ?

    Thanks Eri...I get clear.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center