|
You can replace the string that you are looking for with an empty string, and check the length of the original string with the resulting string. Divide the difference in length by the number of characters in the string that you are looking for to get the number of occurances.
---
b { font-weight: normal; }
|
|
|
|
|
hi friend
how to open GPRS Connection through my pocket pc 2003 (pda) in c#
i have to do two things first i have to open GPRS CONNECTION programmatically in c# then i have to send dataset on server side web service will receive the dataset.
if any one have sample code or snippt how to open gprs connection please
so please help me as soon as possible.
thanks
raj
india
BIG
BIG
|
|
|
|
|
Hello,
I want to be able to update a connection string that I have in my app.config file. This is so that the customer can change the connection to another server or database.
Can anyone give me any example code. I am using C# 2005.
Many thanks in advance,
Steve
|
|
|
|
|
In .NET 2005 there's a new configuration framework that simplifies writing config settings per user or per app. If you add a settings file to your project, you can add settings and then access them directly ( they get written to the file for you ). Check the MSDN for more info. One thing, - I created a new settings file and it didn't work, the file you need is under a folder called 'profile' and you actually access it from Profile.Settings.Default.Propname, where Propname is the setting you created.
Your other option is to open the app.config using an XmlDocument and changing the values using XPath/DOM code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello
I am using my.settings to create a application scope connection string.
The customer would like to change this if they want to connect to another database, and this should update the app.config file with the updated connection string.
My problem I have into the setting and create a connection string (easy). But I don't know and can't find out to update and save the new connection string.
My.Settings.cnnString = "This is example connection" 'Error read-only property
I am using vb.net 2005
Can anyone help,
Thanks in advance,
Steve
|
|
|
|
|
|
Hello
I am using my.settings to create a application scope connection string.
The customer would like to change this if they want to connect to another database, and this should update the app.config file with the updated connection string.
My problem I have into the setting and create a connection string (easy). But I don't know and can't find out to update and save the new connection string.
My.Settings.cnnString = "This is example connection" 'Error read-only property
Can anyone help,
I got this code and it seem it would work. However, there is a problem with the code. I get a "Object reference not set to an instance of an object."
Here my code.
[code]
Dim config As Configuration.Configuration = Configuration.ConfigurationManager.OpenExeConfiguration(Configuration.ConfigurationUserLevel.None)
config.ConnectionStrings.ConnectionStrings("ServiceMasterConnectionString").ConnectionString = "This is new connection " 'Error -
config.Save()
[/code]
Thanks in advance,
Steve
|
|
|
|
|
As I said there's not much point in asking here since we're C# developers and I for one have developed in VB.NET but not recently so don't know about My.Settings, people in the VB.NET forum should know.
Just Google it.
Failing that try phoning
|
|
|
|
|
Hello
I am using my.settings to create a application scope connection string.
The customer would like to change this if they want to connect to another database, and this should update the app.config file with the updated connection string.
My problem I have into the setting and create a connection string (easy). But I don't know and can't find out to update and save the new connection string.
My.Settings.cnnString = "This is example connection" 'Error read-only property
Can anyone help,
I got this code and it seem it would work. However, there is a problem with the code. I get a "Object reference not set to an instance of an object."
Here my code.
<br />
Dim config As Configuration.Configuration = Configuration.ConfigurationManager.OpenExeConfiguration(Configuration.ConfigurationUserLevel.None)<br />
config.ConnectionStrings.ConnectionStrings("ServiceMasterConnectionString").ConnectionString = "This is new connection " 'Error - <br />
config.Save()<br />
Thanks in advance,
Steve
|
|
|
|
|
Christian Graus wrote: the file you need is under a folder called 'profile' and you actually access it from Profile.Settings.Default.Propname,
Oh, so you got it to work finally?
|
|
|
|
|
Hello,
The code I posted did not work, there was an error.
S. Senthil Kumar wrote: the file you need is under a folder called 'profile' and you actually access it from Profile.Settings.Default.Propname,
I am sure what this Profile.Settings.Default.Propname is, can someone possibly give me an example.
Many thanks,
Steve
|
|
|
|
|
I realised there was a folder called Profile with a settings file in it. I hadn't seen it, I'd followed the instructions on the MS site and created a new settings file, which the IDE did, but which then was not mapped to the Profile.Settings stuff. It's all stupid IMO, but I can see now how to make it work. In the meantime, I wrote my own code to serialise a struct with all my settings in it to XML, and to expose those properties via a static class.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello,
thats my problem:
Decimal _ContentDistributionResolution = 0;
....
....
_ContentDistributionResolution = myReader.GetDecimal(12);
...
...
In the Database ist the ContentDistributionResolution column from Datatype Decimal (accuracy: 5)...
The System.Converte methode dosent work...
|
|
|
|
|
Define 'doesn't work', Have you tried this :
object o = myReader.GetDecimal(12);
in the debugger to see what object is being returned ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
ahhh...I am stupid!!! I have used the false Index GetDecimal(13) is the right!!!
Sorry
|
|
|
|
|
In C# how to get the line number and file name from which an exception is raised.
In C++ we have the macro __LINE__ to do that. Want to know the substitute in C#. or Is it possible to use the macro __LINE__ in C#. if YES , let me know how is it possible.
Ashish
|
|
|
|
|
Hello
You will find that in the SystemException.Message property. You might also want to check the SystemException.Data for useful information.
About the __FUNCTION__ macro, you can use Environment.StackTrace to get the name of the current function at anytime.
And no!! You can't call C++ macros in C#.
Regards
|
|
|
|
|
Thanx a lot for the response.
I have checked SystemException it does not gives the line no throwing exception.
and the Environment.StackTrace gives result in the debug build but doesnt work for the release build.
Is there any other way ?? plz let me know
NOthignhere
|
|
|
|
|
Environment.StackTrace works fine in release mode. What makes it doesn't work for you? Another alternative is to use Trace class to make your own trace calls.
Regards
|
|
|
|
|
I have a program that cycles through an XML file and outputs to another file every 1000 records. Thyis works fine until the end of the XML file is reached, when it fails saying my 'root' tag is not closed - although it does for the previous files. It seems to be having issues with recognising the end of the XML file, so can someone please confirm how this is done? Currently I have a while loop to do this, with a for loop inside to cycle through the records, ie:
while (XmlReader.Read())
{
...
for (int i = 1; i <= 100; i++)
{
while (reads in a node here)
{
does the work
}
}
Close the XmlReader and XmlWriter
}
This works fine for the beginning, until the end of the file is reached; is my way of reading the XML file correct (I have also tried XmlReader != null), or is there a better way?
Many thanks.
|
|
|
|
|
Judging by your description of the error have you made sure that you close all the tags you open with XmlWriter?
<br />
<br />
xw.WriteStartDocument must be closed by xw.WriteEndDocument <code>
xw.WriteStartElement must be closed by xw.WriteEndElement (even for the root node)
Just Google it.
Failing that try phoning
|
|
|
|
|
Thanks for the reply.
I do ensure I have a 'closing' tag for every 'opening' one. This works fine for all files (say, 10 files of 100 records each), but on the last file, where the end of the original file is found, it fails. I believe my method to read it is fine, yet it fails (somehow!) when reading the end of the file. So I am really puzzled!
Oh, and I've googled lots to no joy!!!
|
|
|
|
|
When you hit the end-of-file do you make sure that all the nodes are closed in the output stream?
It'd be a help if you could copy & paste the details of the exception thrown as well, so that we can see if it's a reading or writing problem.
Just Google it.
Failing that try phoning
|
|
|
|
|
I do ensure all nodes are closed when the end of file is found - at least I think so, but I am sure it is something in that area that is causing the problem.
As for the exception, there isn't one; the program doesn't complete. The XML file's are created, but in the last one towards the end of the file, in the middle of a record is the message:
"XML page cannot be displayed
The following tags were not closed: message."
Where message is my root node. Yet it closes them in the other files (when the original XML file still has more records to read)...
|
|
|
|
|
Can you show the bits of code which are executed when the end-of file is reached?
Just Google it.
Failing that try phoning
|
|
|
|