Select () certain Row from Table in Database to XML file

Feb 4 2016 3:23 AM
Hello C# Corner ,
 
 I want to select only one row from table and  save that data of the only selsected row in xml file,
That row i want its information will be (TextBox.Text). Any information will be in the textbox it will save data to xml file.
 
this is my Code:
ConnectionString = @"Data Source=LocalDB\SQLEXPRESS;Initial Catalog=TestDB;Integrated Security=True";
connection = new SqlConnection(ConnectionString);
sql = "Select * from Table_Sub where ActivationCode = "" "; // Please can someone help me here.
try
{
connection.Open();
adapter = new SqlDataAdapter(sql, connection);
adapter.Fill(ds);
connection.Close();
ds.WriteXml("Subscription.xml");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
 

Answers (4)