hello,
Can u tell me how can i use try...catch in following coding.
This code is for save the data.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace savita
{
public partial class Form5 : Form
{
DataTable dt;
DataRow dr;
public Form5()
{
InitializeComponent();
}
dt = hosDataSet.Tables["inpatient"];
dr = dt.NewRow();
dr["ipid"] = textBox1.Text;
dr["nm"] = textBox2.Text;
dr["addr"] = textBox3.Text;
dr["phno"] = textBox4.Text;
dr["mobno"] = textBox5.Text;
dr["age"] = textBox6.Text;
dr["bld"] = comboBox1.Text;
dr["adm"] = comboBox2.Text;
dr["bed"] = comboBox3.Text;
// dr["dt"] = dateTimePicker1.Text;
DialogResult result = MessageBox.Show("You Want To Save Data", "Save", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
MessageBox.Show("The Data Is Saved", "save");
dt.Rows.Add(dr);
inpatientTableAdapter.Update(hosDataSet);
this.inpatientTableAdapter.Fill(this.hosDataSet.inpatient);
}
if (result == DialogResult.No)
{
MessageBox.Show("The Data Is Not Saved", "Save");
}
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
comboBox1.Text = "";
comboBox2.Text = "";
comboBox3.Text = "";
}
}
Virusisfound