Hi,
I have the following line in my code:
strConnect = String.Format(" Data Source={0},{1}; Network
Library=DBMSSOC N;Initial Catalog={2};Int egrated 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=DBMSSOC N;Initial
Catalog=test;In tegrated Security=False; Trusted
Connection=Yes; UID=test1;PSW=t est2"
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 1948
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.co mschreef 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=DBMSSOC N;Initial Catalog={2};Int egrated 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=DBMSSOC N;Initial
Catalog=test;In tegrated Security=False; Trusted
Connection=Yes; UID=test1;PSW=t est2"
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.co mschreef 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=DBMSSOC N;Initial Catalog={2};Int egrated 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=DBMSSOC N;Initial
Catalog=test;In tegrated Security=False; Trusted
Connection=Yes; UID=test1;PSW=t est2"
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.co mwrote:
I have the following line in my code:
strConnect = String.Format(" Data Source={0},{1}; Network
Library=DBMSSOC N;Initial Catalog={2};Int egrated 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=DBMSSOC N;Initial
Catalog=test;In tegrated Security=False; Trusted
Connection=Yes; UID=test1;PSW=t est2"
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.co m>
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.co mschreef in bericht
news:MP******** *************@m snews.microsoft .com...
EricW <ie****@home.co mwrote:
>I have the following line in my code:
strConnect = String.Format(" Data Source={0},{1}; Network Library=DBMSSO CN;Initial Catalog={2};Int egrated 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=DBMSSOC N;Initial Catalog=test;I ntegrated 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.co m>
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
not added. Please comment.
Neil
PEP: 349
Title: Generalised String Coercion
|
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 where I can look up
explaination on the String.Format, the format string part like "("{0:.#0}".
What's the trailing 0 and what is that "0:" means? I assume the "#" is the
place holder character for th value obtain after the comma in the code.
...
|
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 & c & d & e
+/- 420ms
|
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 MyVariant = 2 Then MsgBox "MyVariant also equals the value 2"
160 If MyVariant = "" Then HowManyCopies = 1
170 If Not IsNumeric(MyVariant) Then HowManyCopies = 1
MsgBox "OK. HowManyCopies has a value of " & CStr(HowManyCopies)
180 For i =...
|
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 that very same format string from an xml file:
....load xmlNode WorkNode...
| |
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
Message="Input string was not in a correct format."
Source="mscorlib"
|
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 being convert to an Int16
(using Convert.ToInt16). How can that be? There are other text boxes that
are used in the identical fashion and they don't generate the exception.
All there are many other machines running my application that don't...
|
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 call a static method:
public static string ValidateMessage(params...)
|
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. (Sorry, long email)
The first two examples are behaving normal, the thirth is
strange.......
I wrote the following flabbergasting code:
#-------------------------------------------------------------
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |