|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
HI,
How can we get XML values into combo box any suggestions and also how we get URL open on clicking form load and get those values through xml to combobox.please suggest me some technics
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
Please try to explain in better detail what the problem is, what you have tried to do to fix it, where you are stuck, and what help you need.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi,
From below xml file i need to get hospital names in combo box using c# , i have searched in net but i cant find the hint how can we read.
?xml version="1.0" encoding="utf-8" ?>
<hospitals>
<hids>
<hid>1</hid>
<hos_type>0</hos_type>
<hcode>SV</hcode>
<hname>St Vincents</hname>
<address>Australia</address >
<landline>56456456456</landline>
<mobile>569678768</mobile>
<email>bijibtrack1@gmail.com</email>
<status>0</status>
<created_by>fgdfgdfgdfg</created_by>
<created_on>2011-02-26 10:10:50</created_on>
<notes>dfgdfgdfg</notes>
<is_pms>0</is_pms>
<c_insert>1</c_insert>
<c_update>0</c_update>
<c_timezone></c_timezone>
</hids>
<hids>
<hid>2</hid>
<hos_type>0</hos_type>
<hcode>ARC</hcode>
<hname>ARC Clinic</hname>
<address>Australia.</address >
<landline>34563456</landline>
<mobile>34563456</mobile>
<email>bijibtrack1@gmail.com</email>
<status>1</status>
<created_by></created_by>
<created_on>2012-10-10 00:00:00</created_on>
<notes>australia</notes>
<is_pms>0</is_pms>
<c_insert>1</c_insert>
<c_update>0</c_update>
<c_timezone>2011-02-11 18:27:09</c_timezone>
</hids>
|
|
|
|
|
|
yes, i am trying to read data from xml to display in combo box but i am unable to get exact solution..
|
|
|
|
|
So what code did you try, and what did it do that your didn't expect, or not do that you did?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have tried below code but i am not getting the values in combobox
void MainFormLoad(object sender, EventArgs e)
{
string myXmlfile=@"C:\Users\anusha\Documents\SharpDevelop Projects\hospitals.xml";
DataSet ds= new DataSet();
System.IO.FileStream fsReadXml= new System.IO.FileStream
(myXmlfile,System.IO.FileMode.Open);
ds.ReadXml(fsReadXml);
cmbHospitals.DataSource=ds;
cmbHospitals.DisplayMember="name";
}
<pre lang="c#">
|
|
|
|
|
Well, a very quick debugging session and some light thinking would have told you several things:
1) Your XML is missing the opening < and will not process as a result.
2) Your XML is missing the closing tag: </hospitals>
3) You code expects the ComboBox to work out for itself which table to use: don't pass the dataset as the DataSource, pass the table. DataSets can contain multiple tables.
4) There is no "name" data in your XML file. There is "hname" data though...
5) You shouldn't hold the file open: add a using block round the FileStream creator.
DataSet ds = new DataSet();
using (System.IO.FileStream fsReadXml = new System.IO.FileStream(myXmlfile, System.IO.FileMode.Open))
{
ds.ReadXml(fsReadXml);
}
cmbHospitals.DataSource = ds.Tables[0];
cmbHospitals.DisplayMember = "hname";
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks sir for clarifying, I have given the correct coding.I have written below code for displaying hospital names but i am unable to display names.
void MainFormLoad(object sender, EventArgs e)
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load("hospitals.xml");
XmlNodeList hospitals = xDoc.GetElementsByTagName("hospitals");
for (int i = 0; i < hospitals.Count; i++)
{
cmbHospitals.Items.Add(hospitals[i].Attributes["hname"].InnerText);
}
}
|
|
|
|
|
Did you read the code I gave you, at all?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
yes , i have gone through it,but i am trying to get values into combobox, i am totally confused of what i am doing.and what the helpers are trying to guide
|
|
|
|
|
Just copy the code from my post, and paste it into your app. Run your code, and (provided you've fixed the other problems) it should load the hospital names into the combobox.
It did for me when I tested it against your (corrected) data!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks you sir.. I got the required output
|
|
|
|
|
You're welcome!
Do you understand why?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Yes sir, It was mistake in xml code only thats why i am not getting the values.i tried using try and catch blocks to check the error.
|
|
|
|
|
If you run your code in the debugger, it will stop on an unhandled exception and show you where (and what) the problem is - and it will let you look at data, change code, run it again, single step your code ... a whole lot more useful than just changing your code to try and find an error!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
ok sir thank you, for your valuable suggestions i will take your suggestions and do further codings.
|
|
|
|
|
I Need To Read SMS Message in C# using AT Command
|
|
|
|
|
If you are waiting for permission, then consider it given: go right ahead.
If you need something else, then please explain what you have tried, what happened when you tried, where you are stuck, and what help you need.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi all,
First time poster here and excited to interact with the forum.
I'm using C# and Postgres. I rolled my own security to escape the special chars I was aware off (like single quote), but then was advised that I didn't need to do that - parameterization could do it all for me!
So I deleted (archived) my code and replaced it all with parameterized Npgsqlcommands. Great!
However, a bit of testing shows that it doesn't escape single quotes when using NpgsqlCommand.ExecuteReader().
It seems to work fine when I do NpgsqlCommand.ExecuteNonQuery(). I listed my working code at the bottom of this message in case anyone doing this stumbles across it and finds it useful.
I'm kind of a novice, and would really appreciate someone more experienced to look over my code and help me understand what I'm doing wrong.
Here's my method for SQL queries that return data:
public static bool ExecuteSQLQuery(NpgsqlCommand cmdText, out DataTable dataTable)
{
try
{
string connectionString = ConfigurationManager.AppSettings["connectionString"];
NpgsqlConnection sqlConnection = new NpgsqlConnection(connectionString);
sqlConnection.Open();
cmdText.Connection = sqlConnection;
dataTable = new DataTable();
dataTable.Load(cmdText.ExecuteReader(CommandBehavior.CloseConnection));
sqlConnection.Close();
return true;
}
catch(Exception ex)
{ dataTable = new DataTable(); return false; }
}
Here's my code for calling that code:
DataTable dataTable = new DataTable();
NpgsqlCommand sqlCommand = new NpgsqlCommand("SELECT * FROM users.users WHERE (email ilike @email or username ilike @username)");
sqlCommand.Parameters.AddWithValue("email", NpgsqlTypes.NpgsqlDbType.Varchar, email);
sqlCommand.Parameters.AddWithValue("username", NpgsqlTypes.NpgsqlDbType.Varchar, username);
DatabaseConnectivity.ExecuteSQLQuery(sqlCommand, out dataTable)
If I feed it a single quote character it fails.
Thanks in advance for any help.
PS: Here's my working code for SQL that doesn't return any data:
public static bool ExecuteSQLNonQuery(NpgsqlCommand cmdText)
{
try
{
string connectionString = ConfigurationManager.AppSettings["connectionString"];
NpgsqlConnection sqlConnection = new NpgsqlConnection(connectionString);
sqlConnection.Open();
cmdText.Connection = sqlConnection;
cmdText.ExecuteNonQuery();
sqlConnection.Close();
return true;
}
catch (Exception ex)
{ return false; }
}
|
|
|
|
|
Quote: If I feed it a single quote character it fails. How does it fail?
Is there an error message?
What happens that you don't expect, or doesn't happen that you do?
What - exactly - did you do to test it?
What does the debugger show is happening, and where?
Have you tried using:
sqlCommand.Parameters.AddWithValue("@email", NpgsqlTypes.NpgsqlDbType.Varchar, email);
sqlCommand.Parameters.AddWithValue("@username", NpgsqlTypes.NpgsqlDbType.Varchar, username);
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
how I can download usbclass library for win 10?
|
|
|
|