<Aciklamalar>
<Aciklama HaberKodu="20141101AW232013" ResimKodu="20141101AW232013_01">
<![CDATA[
YENİ MALATYASPOR MAÇINDA SAKATLANAN UMAR, KARŞIYAKA DEPLASMANINA GÖTÜRÜLMÜYOR.
]]>
</Aciklama>
<Aciklama HaberKodu="20141101AW232013" ResimKodu="20141101AW232013_02">
<![CDATA[
YENİ MALATYASPOR MAÇINDA SAKATLANAN UMAR, KARŞIYAKA DEPLASMANINA GÖTÜRÜLMÜYOR.
]]>
</Aciklama>
</Aciklamalar>

Select HaberKodu text?

Select <!CDATA text?

Help.Thanks

Recommended Answers

Here you diclare a string variable "Aciklama" But you use as "Aciklama5".
HaberKodu is an Attribute and Aciklama is an Element. Is this the process to set an Attribute value of an Element by using SQL Statement?
On my opinion please check the SQL Statement.

Jump to Post

All 3 Replies

To go through the elements, you have to use LINQ (Language Integrated Query).

string strQuery5 = "insert into gelenhaberaciklama(HaberKodu,Aciklama) values (@HaberKodu5,@Aciklama5)"; 
    SqlConnection con5 = new SqlConnection(strConnString5);
    con5.Open();
    XmlDocument ReadInDocument5 = new XmlDocument();
    ReadInDocument5.Load("XML FİLE");

    String HaberKodu5 = "";
    String Aciklama = ""; 

    foreach (XmlNode node5 in ReadInDocument5.SelectNodes(".//Aciklamalar/Aciklamala"))
    { 
        HaberKodu5 = node5.Attributes["HaberKodu"].InnerText;
        Aciklama5 = node5.ChildNodes[0].InnerText;

        SqlCommand cmd5 = new SqlCommand(strQuery5); 
        cmd5.CommandType = CommandType.Text;
        cmd5.Connection = con5;
        cmd5.Parameters.AddWithValue("@HaberKodu5", HaberKodu5.ToString());
        cmd5.Parameters.AddWithValue("@Aciklama5", Aciklama5.ToString());
        cmd5.ExecuteNonQuery(); 
    }
    con5.Close();
    con5.Dispose();

HaberKodu5 and Aciklama5 insert to null sql. Parametrs null value. Help?

Here you diclare a string variable "Aciklama" But you use as "Aciklama5".
HaberKodu is an Attribute and Aciklama is an Element. Is this the process to set an Attribute value of an Element by using SQL Statement?
On my opinion please check the SQL Statement.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.