16,017,986 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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..
A C swathi
6-Feb-13 6:05am
View
Thank u..I tried this.But I want to search whole rows based on the value in column and have to bind the rows satisfying this conditon(whose installed date is same as what we type for search in UI).But i cant do it with this code.Because i cant select directly the column because which is now present as an xml string..plz tell me a solution for that..
A C swathi
23-Jan-13 4:14am
View
Thanks.But I have to use the batch select query not the join query.whether i have to two datasets and two dataadpters for retrieve datas from two tables.and whether i have to use datarelation here..please reply..
A C swathi
23-Jan-13 4:13am
View
Thanks.I have to use batch select query to retrive datas from two tables.ya i want to show the six columns in a single datagrid.join query cant be used here.Here i am testing the working of batch select query,that should be include in project.Thats why.whether i have to two datasets and two dataadpters for retrieve datas from two tables.and whether i have to use datarelation here..please reply..
A C swathi
23-Jan-13 2:27am
View
thanks..its working
A C swathi
22-Jan-13 1:38am
View
Deleted
Afterall I am a fresher..these api shows only the methods and properties.no sample code.Then how can i implement that..
A C swathi
22-Jan-13 0:45am
View
Thanks..can u please explain with an example.
A C swathi
19-Dec-12 4:38am
View
Thank u...its working now...
A C swathi
19-Dec-12 1:03am
View
Thanks....i tried it...but no updation is occuring in datagrid after deletion..is there any method for selecting a rowindex and based on that we can perform delete operation.like dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index)in windows application
A C swathi
18-Dec-12 22:45pm
View
This is my program...could you please help me to delete a selected row from grid after delete operation in this program...
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.SqlClient;
using System.Data;
namespace WpfApplication1
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
bindgrid();
}
private void bindgrid()
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=book;User ID=sa;Password=nest123@!");
con.Open();
string cmd1 = "select * from book2";
SqlCommand cmd = new SqlCommand(cmd1, con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
cmd.ExecuteNonQuery();
DataTable dt = new DataTable("book2");
sda.Fill(dt);
dataGrid1.ItemsSource = dt.DefaultView;
}
//insert
private void button1_Click(object sender, RoutedEventArgs e)
{
DataTable dt=new DataTable();
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=book;User ID=sa;Password=nest123@!");
con.Open();
try
{
object item=dataGrid1.SelectedItem;
string col1 = (dataGrid1.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text;
string col2 = (dataGrid1.SelectedCells[1].Column.GetCellContent(item) as TextBlock).Text;
string col3 = (dataGrid1.SelectedCells[2].Column.GetCellContent(item) as TextBlock).Text;
string col4 = (dataGrid1.SelectedCells[3].Column.GetCellContent(item) as TextBlock).Text;
string p = "insert into book2 values('" + col1 + "','"+col2+"','"+col3+"','"+col4+"')";
SqlCommand cmd = new SqlCommand(p, con);
cmd.ExecuteNonQuery();
}
catch (SqlException e1)
{
MessageBox.Show(e1.Message.ToString());
}
MessageBox.Show("value inserted");
dataGrid1.Items.Refresh();
con.Close();
}
//update
private void button2_Click(object sender, RoutedEventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=book;User ID=sa;Password=nest123@!");
con.Open();
try
{
object item = dataGrid1.SelectedItem;
string bookid = (dataGrid1.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text;
string name = (dataGrid1.SelectedCells[1].Column.GetCellContent(item) as TextBlock).Text;
string author = (dataGrid1.SelectedCells[2].Column.GetCellContent(item) as TextBlock).Text;
string prize = (dataGrid1.SelectedCells[3].Column.GetCellContent(item) as TextBlock).Text;
SqlCommand cmd = new SqlCommand("update book2 set name=@name,author=@author,prize=@prize where bookid=@bookid", con);
cmd.Parameters.AddWithValue("@bookid", SqlDbType.NVarChar).Value = bookid;
cmd.Parameters.AddWithValue("@name", SqlDbType.NVarChar).Value = name;
cmd.Parameters.AddWithValue("@author", SqlDbType.NVarChar).Value = author;
cmd.Parameters.AddWithValue("@prize", SqlDbType.NVarChar).Value = prize;
A C swathi
18-Dec-12 12:15pm
View
Thanks.I tried it..but the selected row is not deleting from datagrid after performing the delete operations.Is there any solution for that..
A C swathi
18-Dec-12 5:29am
View
Thanks..i have applied this.But still it is not working ...there is no change in the datagrid
Show More