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" xmlns:x="#unknown" />
<textbox horizontalalignment="Left" height="23" margin="144,134,0,0" textwrapping="Wrap" x:name="TbxFn" verticalalignment="Top" width="193" xmlns:x="#unknown" />
<textbox horizontalalignment="Left" height="23" margin="144,77,0,0" textwrapping="Wrap" x:name="TbxLn" verticalalignment="Top" width="193" xmlns:x="#unknown" />
<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" xmlns:x="#unknown" xmlns:wf="#unknown" />
</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