خیالم از بابت کد راحته چون رو 2005 مشکلی نداشت
یه سوال دیگه
اس کیو ال 2008 متغیری به اسم ایمیج داره اون متغیر رو اگه پیکچر باک دات ایمیج توش بزاری کافیه ؟
ولی خوب بفرما
// Constant strings
private const string _CommandText =
"SELECT id,name,family,tt,adress,tell,mobile " +
" FROM customer ";
private const string _ConnectionString =
"Data Source=M-6;Initial Catalog=vc;Integrated Security=True";
// Declare global objects...
SqlConnection objConnection;
SqlDataAdapter objDataAdapter;
DataSet objDataSet;
DataView objDataView;
CurrencyManager objCurrencyManager;
public Customer()
{
InitializeComponent();
objConnection = new SqlConnection(_ConnectionString);
objDataAdapter = new SqlDataAdapter(
_CommandText, objConnection);
InitializeComponent();
}
private void FillDataSetAndView()
{
// Initialize a new instance of the DataSet object...
objDataSet = new DataSet();
// Fill the DataSet object with data...
objDataAdapter.Fill(objDataSet, "customer");
// Set the DataView object to the DataSet object...
objDataView = new DataView(objDataSet.Tables["customer"]);
// Set our CurrencyManager object
// to the DataView object...
objCurrencyManager = (CurrencyManager)(
this.BindingContext[objDataView]);
}
int n;
private void pictureBox6_Click(object sender, EventArgs e)
{
SqlCommand objCommand = new SqlCommand();
// Open the connection, execute the command
objCommand.CommandText = "INSERT INTO customer " +
" (id,name,family,tt,adress,tell,mobile) " +
" VALUES(@id,@name,@family,@tt,@adress,@tell,@mobile );";
// Parameter for the title column...
objCommand.Parameters.AddWithValue("@id", Convert.ToInt16(txtid.Text));
objCommand.Parameters.AddWithValue("@name", txtname.Text);
objCommand.Parameters.AddWithValue("@family", txtfamily.Text);
objCommand.Parameters.AddWithValue("@tt", txtbdate.Text);
objCommand.Parameters.AddWithValue("@adress", txtadress.Text);
objCommand.Parameters.AddWithValue("@tell", txttel.Text);
objCommand.Parameters.AddWithValue("@mobile", txtmobile.Text);
// Fillid();
objCommand.Connection = objConnection;
objConnection.Open();
try
{
objCommand.ExecuteNonQuery();
}
catch (SqlException SqlExceptionErr)
{
MessageBox.Show(SqlExceptionErr.Message);
}
// Close the connection...
objConnection.Close();
// Fill the dataset and bind the fields...
FillDataSetAndView();