Click here to Skip to main content
15,886,810 members

Comments by A C swathi (Top 16 by date)

A C swathi 7-Feb-13 22:29pm View    
i have just tried this in a local application.This pgm is to bind the value of installed date to textbox.Below given the code sample.

using System;
using System.Collections.Generic;
using System.Linq;

using System.Text;
using System.Windows;
using System.Windows.Controls;

using System.Windows.Data;
using System.Windows.Documents;

using System.Windows.Input;
using System.Windows.Media;

using System.Windows.Media.Imaging;
using System.Windows.Navigation;

using System.Windows.Shapes;
using System.Data;
using System.Data.SqlClient;

using System.Xml;
using System.IO;
namespace WpfApplication1{ ///

/// Interaction logic for MainWindow.xaml ///


public partial class MainWindow : Window
{
public MainWindow()

{
InitializeComponent();
try
{

SqlConnection con = new SqlConnection("Data Source=NIP007\\SQLEXPRESS;Initial Catalog=test;User ID=sa;Password=nest123@!");

con.Open();

string query = "SELECT [partinfo].query('.//InstalledDate').value('.','VARCHAR(MAX)')FROM [test]";

SqlCommand cmd = new SqlCommand(query, con);

// StringBuilder builder=new StringBuilder();

// string PartInfo=string.Empty;

SqlDataReader dr = cmd.ExecuteReader();

while (dr.Read())

{

string str5 =dr.ToString();

if (!string.IsNullOrEmpty(str5))

{
textBox1.Text=str5;

}
}

}
catch(Exception ex)
{

}
}
}}

but its showing exception as i said earlier..
A C swathi 7-Feb-13 7:04am View    
sorry..i jst tried whether the value is passing by putting breakpoint.Then its k.bt when running its showing an exception .which is "Cannot find either column "PartInfo" or the user-defined function or aggregate "PartInfo.query", or the name is ambiguous".where partinfo is the column name,that column content is in the form of xmlstring.and i have to get the value of installed date from this xml string and the partinfo is one of the column present in a table called test.how can i solve the exception..i used the first query that u have given
.
A C swathi 7-Feb-13 5:31am View    
Deleted
Thank u..its working now..
A C swathi 7-Feb-13 4:27am View    
yes.i meant that section.i have to use this query in a pgm.in that cant write the column xmldatacolumn directly.coz which is now present in xmlstring..at that time what i can do..Plz help me.
A C swathi 7-Feb-13 1:36am View    
Thank u..bt the pblm is still existing.i am getting my table as xmlstring in pgm so cant specify the columns inside that in a select query..i just want the values inside the columns ,i cant specify the value directly in query.Because the value will be changed in xml string depending on the user.i have to fetch the datas based on what he is passing..There may be thousands of user so how can i do this..Is there any solution for that..Thanks in advance..