Hi,
I have the following line in my code:
strConnect = String.Format("Data Source={0},{1};Network
Library=DBMSSOCN;Initial Catalog={2};Integrated Security=False;Trusted
Connection=Yes;UID={3};PSW={4};", myServer, myDBPort, Database.Name,
myDBUsername, myDBPassword)
with: myServer = "1.2.3.4"
myDBPort = "1344"
Database.Name = "test"
myDBUsername = "test1"
myDBPassword = "test2"
the strConnect should look like:
"Data Source=1.2.3.4,1344;Network Library=DBMSSOCN;Initial
Catalog=test;Integrated Security=False;Trusted
Connection=Yes;UID=test1;PSW=test2"
But.... it looks like this: "Data Source=1.2.3.4
No ending " and no rest of the string.
If I take out the variables and just hardcode the info, there is no problem.
Why is the string not ending with " after the IP address?
The same happens if I hard-code the IP. Then there is no ending " after the
portnumber.
Can someone help me with this? I'm stuck now...
rg,
Eric 5 1905
Just noticed that the variable myServer is not "1.2.3.4" but "1.2.3.4
Which is strange since it is set by a string property from a class.
"EricW" <ie****@home.comschreef in bericht
news:48***********************@news.kpnplanet.nl.. .
Hi,
I have the following line in my code:
strConnect = String.Format("Data Source={0},{1};Network
Library=DBMSSOCN;Initial Catalog={2};Integrated Security=False;Trusted
Connection=Yes;UID={3};PSW={4};", myServer, myDBPort, Database.Name,
myDBUsername, myDBPassword)
with: myServer = "1.2.3.4"
myDBPort = "1344"
Database.Name = "test"
myDBUsername = "test1"
myDBPassword = "test2"
the strConnect should look like:
"Data Source=1.2.3.4,1344;Network Library=DBMSSOCN;Initial
Catalog=test;Integrated Security=False;Trusted
Connection=Yes;UID=test1;PSW=test2"
But.... it looks like this: "Data Source=1.2.3.4
No ending " and no rest of the string.
If I take out the variables and just hardcode the info, there is no
problem.
Why is the string not ending with " after the IP address?
The same happens if I hard-code the IP. Then there is no ending " after
the portnumber.
Can someone help me with this? I'm stuck now...
rg,
Eric
found where the problem originates... it's the encryption class before it...
"EricW" <ie****@home.comschreef in bericht
news:48***********************@news.kpnplanet.nl.. .
Hi,
I have the following line in my code:
strConnect = String.Format("Data Source={0},{1};Network
Library=DBMSSOCN;Initial Catalog={2};Integrated Security=False;Trusted
Connection=Yes;UID={3};PSW={4};", myServer, myDBPort, Database.Name,
myDBUsername, myDBPassword)
with: myServer = "1.2.3.4"
myDBPort = "1344"
Database.Name = "test"
myDBUsername = "test1"
myDBPassword = "test2"
the strConnect should look like:
"Data Source=1.2.3.4,1344;Network Library=DBMSSOCN;Initial
Catalog=test;Integrated Security=False;Trusted
Connection=Yes;UID=test1;PSW=test2"
But.... it looks like this: "Data Source=1.2.3.4
No ending " and no rest of the string.
If I take out the variables and just hardcode the info, there is no
problem.
Why is the string not ending with " after the IP address?
The same happens if I hard-code the IP. Then there is no ending " after
the portnumber.
Can someone help me with this? I'm stuck now...
rg,
Eric
EricW <ie****@home.comwrote:
I have the following line in my code:
strConnect = String.Format("Data Source={0},{1};Network
Library=DBMSSOCN;Initial Catalog={2};Integrated Security=False;Trusted
Connection=Yes;UID={3};PSW={4};", myServer, myDBPort, Database.Name,
myDBUsername, myDBPassword)
with: myServer = "1.2.3.4"
myDBPort = "1344"
Database.Name = "test"
myDBUsername = "test1"
myDBPassword = "test2"
the strConnect should look like:
"Data Source=1.2.3.4,1344;Network Library=DBMSSOCN;Initial
Catalog=test;Integrated Security=False;Trusted
Connection=Yes;UID=test1;PSW=test2"
But.... it looks like this: "Data Source=1.2.3.4
No ending " and no rest of the string.
If I take out the variables and just hardcode the info, there is no problem.
Why is the string not ending with " after the IP address?
The same happens if I hard-code the IP. Then there is no ending " after the
portnumber.
Can someone help me with this? I'm stuck now...
How are you displaying the result? My *guess* is that you're using a
windows forms control, which will see a null character (\u0000) as a
string terminator - so I suspect you've got a null character in
myServer. How are you getting that data?
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
You've guessed it right, the null values terminated my stringbuild. :-)
Thanks, though!
Eric
"Jon Skeet [C# MVP]" <sk***@pobox.comschreef in bericht
news:MP*********************@msnews.microsoft.com. ..
EricW <ie****@home.comwrote:
>I have the following line in my code:
strConnect = String.Format("Data Source={0},{1};Network Library=DBMSSOCN;Initial Catalog={2};Integrated Security=False;Trusted Connection=Yes;UID={3};PSW={4};", myServer, myDBPort, Database.Name, myDBUsername, myDBPassword)
with: myServer = "1.2.3.4" myDBPort = "1344" Database.Name = "test" myDBUsername = "test1" myDBPassword = "test2"
the strConnect should look like:
"Data Source=1.2.3.4,1344;Network Library=DBMSSOCN;Initial Catalog=test;Integrated Security=False;Trusted Connection=Yes;UID=test1;PSW=test2"
But.... it looks like this: "Data Source=1.2.3.4
No ending " and no rest of the string. If I take out the variables and just hardcode the info, there is no problem.
Why is the string not ending with " after the IP address? The same happens if I hard-code the IP. Then there is no ending " after the portnumber.
Can someone help me with this? I'm stuck now...
How are you displaying the result? My *guess* is that you're using a
windows forms control, which will see a null character (\u0000) as a
string terminator - so I suspect you've got a null character in
myServer. How are you getting that data?
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Neil Schemenauer |
last post by:
The title is perhaps a little too grandiose but it's the best I
could think of. The change is really not large. Personally, I
would be happy enough if only %s was changed and the built-in was...
|
by: Alpha |
last post by:
Hi, I'm maintaining C# code and am fairly new with C# programming. I'm
looking for codes that's droping the 2nd digit of a nuber printed out and I
suspect it's the code below. Can someone tell me...
|
by: Dominique Vandensteen |
last post by:
after the very small & vs string.format discussion I did some speed tests...
loop of 1.000.000 concatenations of 5 public string variables in a class
gave following results:
result = a & b...
|
by: MLH |
last post by:
120 MyString = "How many copies of each letter do you need?"
150 MyVariant = InputBox(MyString, "How Many?", "3")
If MyVariant = "2" Then MsgBox "MyVariant equals the string '2'"
If...
|
by: Scewbedew |
last post by:
Suppose I have the following code:
string myFormat = "Line1/nLine 2";
string formattedString = string.Format(myFormat);
....that would produce a 2-line output as expected.
But if I load...
|
by: Remi THOMAS |
last post by:
Hi,
When you execute this line of code
string script = string.Format("foreach (GroupDoc gdoc in
{0}.SetGroup(\"{1}\") {\r\n", "p1", "p2");
You get
System.FormatException was unhandled...
|
by: Jen |
last post by:
One user of my application is experiencing an exception "input string not in
correct format". But it makes no sense where it is occurring. It is
occurring when a string from a textbox ("172") is...
|
by: BA |
last post by:
Hello,
I have a very strange code behavior that I cannot make heads or tails of:
I have c# code being executed in BizTalk assemblies which is acting very
strangely.
In my BizTalk process I...
|
by: Dox33 |
last post by:
I ran into a very strange behaviour of raw_input().
I hope somebody can tell me how to fix this.
(Or is this a problem in the python source?)
I will explain the problem by using 3 examples....
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |