Connecting Tech Pros Worldwide Forums | Help | Site Map

string error

Tiago Costa
Guest
 
Posts: n/a
#1: Nov 16 '05
I have a string that need to have the " char inside, but this give me an
error: end of the sring, how can i make the " a char of the string?

string comando = "OSQL -Usa -Psa -n -Q "BACKUP DATABASE Rendas TO DISK =
'c:\Rendas.dat_bak'"";







Arild Bakken
Guest
 
Posts: n/a
#2: Nov 16 '05

re: string error


Use the escape character:

string commando = "OSQL -Usa -Psa -n -Q \"BACKUP DATABASE Rendas TO DISK =
'c:\\Rendas.dat_bak'\"";

or prefix with @ character:

string comando = @"OSQL -Usa -Psa -n -Q "BACKUP DATABASE Rendas TO DISK =
'c:\Rendas.dat_bal'"";

Arild

"Tiago Costa" <aaaaa@aaaa.pt> wrote in message
news:egdUITVeEHA.3988@tk2msftngp13.phx.gbl...[color=blue]
> I have a string that need to have the " char inside, but this give me an
> error: end of the sring, how can i make the " a char of the string?
>
> string comando = "OSQL -Usa -Psa -n -Q "BACKUP DATABASE Rendas TO DISK =
> 'c:\Rendas.dat_bak'"";
>
>
>
>
>
>[/color]


Lars Moastuen
Guest
 
Posts: n/a
#3: Nov 16 '05

re: string error


Use double-quotes ("") or maybe (\")

Lars Moastuen

On Tue, 3 Aug 2004 13:24:08 +0100, Tiago Costa <aaaaa@aaaa.pt> wrote:
[color=blue]
> I have a string that need to have the " char inside, but this give me an
> error: end of the sring, how can i make the " a char of the string?
>
> string comando = "OSQL -Usa -Psa -n -Q "BACKUP DATABASE Rendas TO DISK =
> 'c:\Rendas.dat_bak'"";
>
>
>
>
>
>[/color]



--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Daniel Bass
Guest
 
Posts: n/a
#4: Nov 16 '05

re: string error


Prefixing with the @ would mean you'd need to double up on the quotes...

string comando = @"OSQL -Usa -Psa -n -Q ""BACKUP DATABASE Rendas TO DISK =
'c:\Rendas.dat_bal'""";

"Arild Bakken" <arildb_@hotmail.com> wrote in message
news:e7OPBZVeEHA.3944@tk2msftngp13.phx.gbl...[color=blue]
> Use the escape character:
>
> string commando = "OSQL -Usa -Psa -n -Q \"BACKUP DATABASE Rendas TO DISK[/color]
=[color=blue]
> 'c:\\Rendas.dat_bak'\"";
>
> or prefix with @ character:
>
> string comando = @"OSQL -Usa -Psa -n -Q "BACKUP DATABASE Rendas TO DISK =
> 'c:\Rendas.dat_bal'"";
>
> Arild
>
> "Tiago Costa" <aaaaa@aaaa.pt> wrote in message
> news:egdUITVeEHA.3988@tk2msftngp13.phx.gbl...[color=green]
> > I have a string that need to have the " char inside, but this give me an
> > error: end of the sring, how can i make the " a char of the string?
> >
> > string comando = "OSQL -Usa -Psa -n -Q "BACKUP DATABASE Rendas TO DISK =
> > 'c:\Rendas.dat_bak'"";
> >
> >
> >
> >
> >
> >[/color]
>
>[/color]


Shiva
Guest
 
Posts: n/a
#5: Nov 16 '05

re: string error


Escape embedded " (double-quote) characters using '\'.

string comando = "OSQL -Usa -Psa -n -Q \"BACKUP DATABASE Rendas TO DISK =
'c:\Rendas.dat_bak'\"";
"Tiago Costa" <aaaaa@aaaa.pt> wrote in message
news:egdUITVeEHA.3988@tk2msftngp13.phx.gbl...
I have a string that need to have the " char inside, but this give me an
error: end of the sring, how can i make the " a char of the string?

string comando = "OSQL -Usa -Psa -n -Q "BACKUP DATABASE Rendas TO DISK =
'c:\Rendas.dat_bak'"";







Morten Wennevik
Guest
 
Posts: n/a
#6: Nov 16 '05

re: string error


>[color=blue]
> or prefix with @ character:
>
> string comando = @"OSQL -Usa -Psa -n -Q "BACKUP DATABASE Rendas TO DISK =
> 'c:\Rendas.dat_bal'"";
>[/color]

No, @ means ignore escape characters, meaning \ is treated as a regular character.

--
Happy coding!
Morten Wennevik [C# MVP]
Arild Bakken
Guest
 
Posts: n/a
#7: Nov 16 '05

re: string error


That's true... been too long on vacation I guess :)


Arild

"Morten Wennevik" <MortenWennevik@hotmail.com> wrote in message
news:opsb5ph6vjklbvpo@morten_x.edunord...[color=blue][color=green]
> >
> > or prefix with @ character:
> >
> > string comando = @"OSQL -Usa -Psa -n -Q "BACKUP DATABASE Rendas TO DISK[/color][/color]
=[color=blue][color=green]
> > 'c:\Rendas.dat_bal'"";
> >[/color]
>
> No, @ means ignore escape characters, meaning \ is treated as a regular[/color]
character.[color=blue]
>
> --
> Happy coding!
> Morten Wennevik [C# MVP][/color]


Tiago Costa
Guest
 
Posts: n/a
#8: Nov 16 '05

re: string error


OK Problem resolved

Thanks to everybody

"Shiva" <shiva_sm@online.excite.com> escreveu na mensagem
news:eTsOBaVeEHA.3680@TK2MSFTNGP11.phx.gbl...[color=blue]
> Escape embedded " (double-quote) characters using '\'.
>
> string comando = "OSQL -Usa -Psa -n -Q \"BACKUP DATABASE Rendas TO DISK =
> 'c:\Rendas.dat_bak'\"";
> "Tiago Costa" <aaaaa@aaaa.pt> wrote in message
> news:egdUITVeEHA.3988@tk2msftngp13.phx.gbl...
> I have a string that need to have the " char inside, but this give me an
> error: end of the sring, how can i make the " a char of the string?
>
> string comando = "OSQL -Usa -Psa -n -Q "BACKUP DATABASE Rendas TO DISK =
> 'c:\Rendas.dat_bak'"";
>
>
>
>
>
>
>[/color]


Andy
Guest
 
Posts: n/a
#9: Nov 16 '05

re: string error


yeah this is correct
Andy

"Shiva" wrote:
[color=blue]
> Escape embedded " (double-quote) characters using '\'.
>
> string comando = "OSQL -Usa -Psa -n -Q \"BACKUP DATABASE Rendas TO DISK =
> 'c:\Rendas.dat_bak'\"";
> "Tiago Costa" <aaaaa@aaaa.pt> wrote in message
> news:egdUITVeEHA.3988@tk2msftngp13.phx.gbl...
> I have a string that need to have the " char inside, but this give me an
> error: end of the sring, how can i make the " a char of the string?
>
> string comando = "OSQL -Usa -Psa -n -Q "BACKUP DATABASE Rendas TO DISK =
> 'c:\Rendas.dat_bak'"";
>
>
>
>
>
>
>
>[/color]
Closed Thread