473,320 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

sql query in XML database

Dear All,


I have to make sql query in XML database with Visual Studio C#.
I especially need this>>>"SELECT* FROM AAA WHERE BBB='"+ textBox1.Text + "'";


Thanks for coming helps..
Jul 8 '07 #1
2 3504
Dököll
2,364 Expert 2GB
Dear All,


I have to make sql query in XML database with Visual Studio C#.
I especially need this>>>"SELECT* FROM AAA WHERE BBB='"+ textBox1.Text + "'";


Thanks for coming helps..
Hello, mfkanca!

I came across the below and thought it helpful:

http://www.w3schools.com/xquery/xquery_example.asp

Be sure to read through it all, pretty fancy stuff. Also, please tell us if the C# portion in your project was questionable, can foward or you can in turn post there. Let us know if above link was helpful or what you got out of it, okay.

Good luck and welcome!

Dököll
Jul 9 '07 #2
Here is the complete answer for myself at the end.There is add,remove,update,find commands.


namespace MOVIE_DATABASE_with_XML
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private XmlNodeList nodes;
private XmlElement elm0;
private XmlElement elm1;
private XmlElement elm2;
private XmlElement elm3;
private XmlElement elm4;
private XmlElement elm5;
private XmlElement elm6;

string saveload = "C:\\Documents and Settings\\fatih\\Desktop\\MovieDatabase.xml";
XmlDocument xmldoc = new XmlDocument();
private void add_Click(object sender, EventArgs e)
{
try
{


xmldoc.Load(saveload);

elm0 = xmldoc.CreateElement("Movie");
elm1 = xmldoc.CreateElement("Name");
elm2 = xmldoc.CreateElement("Release_Date");
elm3 = xmldoc.CreateElement("Genre");
elm4 = xmldoc.CreateElement("Studio");
elm5 = xmldoc.CreateElement("Runtime");
elm6 = xmldoc.CreateElement("Picture");

elm1.InnerText = textBox1.Text;
elm2.InnerText = textBox2.Text;
elm3.InnerText = textBox3.Text;
elm4.InnerText = textBox4.Text;
elm5.InnerText = textBox5.Text;
elm6.InnerText = textBox6.Text;

elm0.AppendChild(elm1);
elm0.AppendChild(elm2);
elm0.AppendChild(elm3);
elm0.AppendChild(elm4);
elm0.AppendChild(elm5);
elm0.AppendChild(elm6);

xmldoc.DocumentElement.InsertAfter(elm0, xmldoc.DocumentElement.LastChild);
xmldoc.Save(saveload);
MessageBox.Show("It has been just added");

}
catch (Exception ex)
{
MessageBox.Show("" + ex.Message);
}
}

private void remove_Click(object sender, EventArgs e)
{
try
{


xmldoc.Load(saveload);
nodes = xmldoc.SelectNodes("/MOVIE_DATABASE//Movie[Name='" + textBox1.Text + "']");

foreach (XmlNode node in nodes)
node.RemoveAll();
xmldoc.Save(saveload);
MessageBox.Show("It has been just removed");
}
catch (Exception ex)
{
MessageBox.Show("" + ex.Message);

}
}

private void update_Click(object sender, EventArgs e)
{
try
{

xmldoc.Load(saveload);
nodes = xmldoc.SelectNodes("/MOVIE_DATABASE//Movie[Name='IceAge']");
foreach (XmlNode node in nodes)
{

node.ChildNodes[1].InnerText = textBox1.Text;
node.ChildNodes[2].InnerText = textBox2.Text;
node.ChildNodes[3].InnerText = textBox3.Text;
node.ChildNodes[4].InnerText = textBox4.Text;
node.ChildNodes[5].InnerText = textBox5.Text;
node.ChildNodes[6].InnerText = textBox6.Text;
}

xmldoc.Save(saveload);
MessageBox.Show("It has been just updated");
}
catch (Exception ex)
{
MessageBox.Show("" + ex.Message);
}


}

private void find_Click(object sender, EventArgs e)
{
try
{

xmldoc.Load(saveload);

nodes = xmldoc.SelectNodes("//MOVIE_DATABASE//Movie[Name='" + textBox1.Text + "']");
foreach (XmlNode node in nodes)
{

textBox1.Text = node.ChildNodes[0].InnerText;
textBox2.Text = node.ChildNodes[1].InnerText;
textBox3.Text = node.ChildNodes[2].InnerText;
textBox4.Text = node.ChildNodes[3].InnerText;
textBox5.Text = node.ChildNodes[4].InnerText;
textBox6.Text = node.ChildNodes[5].InnerText;
}

}
catch(Exception ex)
{
MessageBox.Show("" + ex.Message);


}
}

private void button4_Click(object sender, EventArgs e)
{
openFileDialog1.InitialDirectory = @"C:\Documents and Settings\fatih\Belgelerim\Resimlerim";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox6.Text = openFileDialog1.FileName;
pictureBox1.Image = Image.FromFile(textBox6.Text);
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;



}
}
Aug 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: jaysonsch | last post by:
Hello! I am having some problems with a database query that I am trying to do. I am trying to develop a way to search a database for an entry and then edit the existing values. Upon submit, the...
3
by: Nick Truscott | last post by:
<? // scoreinput.php - input a match score when match selected from list ?> <html> <head> <basefont face="Verdana"> </head> <body>
15
by: Rolan | last post by:
There must be a way to enhance the performance of a query, or find a plausible workaround, but I seem to be hitting a wall. I have tried a few tweaks, however, there has been no improvement. ...
7
by: Bernard Lebel | last post by:
Hello, I'm stumbled at a serious problem, and quite frankly getting desparate. This is a rather long-winded one so I'll try to get straight to the point. I have this Python program, that...
13
by: forbes | last post by:
Hi, I have a user that used the Query Wizard to create a query in Access. Now she claims that her master table is missing all the data that was excluded from the query. Can you create anything...
1
by: Pradeep83 | last post by:
Hi All Problem : I am unable to retrieve the data from the table in postgres database using C application which i have written in solaris os. Query: How to check whether connection is there...
2
by: Bob Alston | last post by:
If you have an access form with record source being a straightforward query and where clause in the form definition, will the query be sent to the back end jet/Access database and executed there,...
3
by: mnjkahn via AccessMonster.com | last post by:
I'm running Access 2003, modifying a query that has over 45 fields. When I right click on the field name in Query Design View, and then click Build, Access crashes before the Build window...
32
by: wexx | last post by:
I have been looking for some time now (reading books off Safari, searching through forums,etc) I have found no solution to this problem. I turn to anyone of you that may be able to help me. I'm...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
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
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.