TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
JOHN JOHNNNY
NA
190
140.2k
WPF- How to save and retrieve details from database
Mar 29 2015 11:20 AM
I want to develop an desktop app to save and retrieve details from database, but am having a little hitch
am getting errors in my code, kindly advice below are the required code
xaml
<Grid>
<TextBox HorizontalAlignment="Left" Height="23" Margin="144,28,0,0" TextWrapping="Wrap" x:Name="TbxId" VerticalAlignment="Top" Width="193"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="144,134,0,0" TextWrapping="Wrap" x:Name="TbxFn" VerticalAlignment="Top" Width="193"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="144,77,0,0" TextWrapping="Wrap" x:Name="TbxLn" VerticalAlignment="Top" Width="193"/>
<Label Content="Student ID" HorizontalAlignment="Left" Margin="10,28,0,0" VerticalAlignment="Top" Width="101"/>
<Label Content="Last Name" HorizontalAlignment="Left" Margin="10,134,0,0" VerticalAlignment="Top" Width="101"/>
<Label Content="First Name" HorizontalAlignment="Left" Margin="10,77,0,0" VerticalAlignment="Top" Width="101"/>
<Button x:Name="BtnSave" Content="Save" HorizontalAlignment="Left" Margin="23,206,0,0" VerticalAlignment="Top" Width="75" />
<Button x:Name="BtnBrowse" Content="Browse" HorizontalAlignment="Left" Margin="149,206,0,0" VerticalAlignment="Top" Width="75" Click="Save"/>
<Button x:Name="BtnShow" Content="Show" HorizontalAlignment="Left" Margin="294,206,0,0" VerticalAlignment="Top" Width="75"/>
<WindowsFormsHost Grid.Column="0" Margin="448,28,75,243">
<wf:PictureBox x:Name="pictureBox1" Height="150" Width="150" SizeMode="StretchImage"/>
</WindowsFormsHost>
</Grid>
cs
private void Browse(object sender, RoutedEventArgs e)
{
SqlConnection cn = SqlConnection(global::DatabaseApp.Properties.Settings.Default.Database1ConnectionString);
try
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif|All Files(*.*)|*.*";
dlg.Title = "Select Student Picture";
if (dlg.ShowDialog() == DialogResult.OK)
{
imgLoc = dlg.FileName.ToString();
picStu.ImageLocation = imgLoc;
}
}
catch(Exception ex)
{
System.Windows.MessageBox.Show(ex.Message);
}
}
Thank you
Reply
Answers (
3
)
how to display parent and child records in wpf datagrid
[WPF] AutoCompleteBox: set parameters from code behind