|
Hi,
Change the method parameter from String to SqlDbType.
himanshu
|
|
|
|
|
How about System.Enum.Parse ( typeof(System.Data.SqlDbType) , "datetime" , true ) ?
|
|
|
|
|
thanks it worked fine for my application
|
|
|
|
|
|
How can i load in a XmlDocument an xml file (from text file) that in the tag contain any type of char ? How can encode this ?
If my file contain char as "&" or "°" there is an exception (Xml.XmlException Errore durante l'analisi di EntityName).
I try with this but don't work:
Encoding enc = Encoding.ASCII;
FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.None);
StreamReader sr = new StreamReader(fs,enc);
string response = sr.ReadToEnd();
XmlDocument xml = new XmlDocument();
xml.LoadXml(response);
fs.Close();
sr.Close();
The exception is Xml.XmlException Errore durante l'analisi di EntityName.
|
|
|
|
|
Well as far as I know it is not allowed to use all chars in entity-names. There is a strict rule for tag-names. Maybe you could post a bit of your xml-file, so that we can identify the problem.
Regards
Sebastian
|
|
|
|
|
The problem isn't the tag-names but their content.
The exception occur when in the content of a tag (<tag> abc & avc n° ) there are particular char as & or °
|
|
|
|
|
You could replace all special characters with their escape characters before reading the xml. Maybe this helps.
|
|
|
|
|
How can i replace it ? can you give me an example of code ?
|
|
|
|
|
Not the best method but maybe
response = response.Replace( "&", "&");
By the way, do you have an xml-declaration in your file (sort of <?xml version="1.0" encoding="UTF-8"?> )?
|
|
|
|
|
I dont' have an xml-declaration...however if i add it there is always the same exception.
To use replace i must know all possible incorrect char... i would like to find a method valid for all possible char that may occur in the file.
Edit:
if i use utf8 encoding and replace of &, program work well with my current file xml.
I hope in future don't occur another char that create same problem. I think that & is properly of XML standard and so cause this exception.
modified on Wednesday, June 17, 2009 8:14 AM
|
|
|
|
|
If the file doesn't contain a well-formed XML document you'll need to fix it.
|
|
|
|
|
For the moment i use utf8 encoding and replace all the & with &
What are the other possible char that may cause the Exception ?
|
|
|
|
|
|
I am using abstract classes in my project, meanwhile i want to use overloaded Constructors to those classes, then how to call those overloaded constructors, because abstract classes cannot instantiate.
can any one please answer me?
Thanks in advance...
|
|
|
|
|
An abstract class can have implementations though.
public abstract class BaseClass
{
protected BaseClass()
{ }
protected BaseClass(int id)
{
ID = id;
}
public int ID
{
get;
private set;
}
public string Text
{
get;
internal set;
}
}
public class DerivedClass : BaseClass
{
public DerivedClass() : base() { }
public DerivedClass(int id) : base(id) { }
public DerivedClass(int id, string text) : base(id)
{
Text = text;
}
}
[Edit] Forgot to mark the abstract class's constructors as protected[/Edit]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Wednesday, June 17, 2009 4:57 AM
|
|
|
|
|
The same as calling any base class constructors?
|
|
|
|
|
i'm try to register a formclosing event with a button click event but i get the error saying "Cannot assign to 'button1_Click' because it is a 'method group'"
this is the code i'm using
private void Form1_FormClosing(object sender,EventArgs e)
{
DialogResult ds = MessageBox.Show("exit?", "exit", MessageBoxButtons.YesNo);
FormClosingEventArgs ee = (FormClosingEventArgs)e;
if (ds == DialogResult.Yes)
{
ee.Cancel = false;
}
else
{
ee.Cancel = true;
}
}
private void Form1_Load(object sender, EventArgs e)
{
button1_Click+= Form1_FormClosing;
}
what might be the problem here ?
|
|
|
|
|
prasadbuddhika wrote: button1_Click+= Form1_FormClosing;
well you dont add event handlers like that. try...
button1.Click += new EventHandler(Form1_FormClosing);
but your Form1_FormClosing method is just a handler and will not close the form.
what you should do is have the FormClosing handler on the Form.Closing event. Then have the button click event call
Form.Close();
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
button1_Click is a method. I think you meant button1.Click
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
oh ! great , thanx,i really deceived , thank you again.
|
|
|
|
|
in my app there is a button called exit, i want to prompt a dialog box confirming the exit.now i'm trying handle the closing event of the control box, that is why i'm trying to register the formclosing event with click event , but i get a deligate problem because of eventarg and formclosingeventarg, so any one can help me with this
|
|
|
|
|
Hi,
In your original code the signature of the delegate is incorrect
[Edit: typo corrected]
private void Form1_FormClosing(object sender, EventArgs e)
should be
private void Form1_FormClosing(object sender, FormClosingEventArgs e).
Alan.
modified on Wednesday, June 17, 2009 6:23 AM
|
|
|
|
|
This is pretty simple. You need to call Close from the button's Click event handler and display the message box or whatever in the form's FormClosing event handler, setting e.Cancel if you don't want to close:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
FormClosing += new FormClosingEventHandler(Form1_FormClosing);
btnExit.Click += new EventHandler(btnExit_Click);
}
void btnExit_Click(object sender, EventArgs e)
{
Close();
}
void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = (MessageBox.Show(
this,
"Do you really wish to exit this application?",
"Confirm Exit",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2) != DialogResult.Yes);
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I wondered about that when I saw your original code.
private void Form1_FormClosing(object sender,EventArgs e)
{
DialogResult ds = MessageBox.Show("exit?", "exit", MessageBoxButtons.YesNo);
FormClosingEventArgs ee = (FormClosingEventArgs)e;
if (ds == DialogResult.Yes)
{
ee.Cancel = false;
}
else
{
ee.Cancel = true;
}
}
private void Form1_Load(object sender, EventArgs e)
{
button1_Click+= Form1_FormClosing;
}
Are you perhaps thinking that linking the ForClosing event to a button click will cause the button to generate the FormClosing event and thus close the form? If so, that will not happen.
What you need to do in your button Click event is "this.Close()" which will close the current form. That will raise the FormClosing event where you can then ask for confirmation:
private void Form1_FormClosing(object sender,EventArgs e)
{
DialogResult ds = MessageBox.Show("exit?", "exit", MessageBoxButtons.YesNo);
if (e is FormClosingEventArgs)
{
FormClosingEventArgs ee = e as FormClosingEventArgs;
ee.Cancel = (ds == DialogResult.No);
}
}
private void Button1_Click(object sender, EventArgs e)
{
this.Close();
}
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|