السلام عليكم
هذا كود اضافة بيانات لقاعدة اكسيس
وقد حولت القاعدة الى sql
الرجاء تعديل الكود ليتعامل بالاضافة مع قاعدة sql
اولا كود الربط
static string ConStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\GMM\TEST.accdb;Persist Security Info=False ";
OleDbConnection Conn = new OleDbConnection(ConStr);
كود الاضافة
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
{
// MessageBox.Show(e.KeyChar.GetHashCode().ToString()); to get hash code for enter its = 851981
if (textBox1.Text != "")
if (e.KeyChar.GetHashCode() == 851981)
{
string s = "'";
OleDbCommand SaveInto = new OleDbCommand();
SaveInto.Connection = Conn;
SaveInto.CommandType = CommandType.Text;
SaveInto.CommandText = "Insert Into Data_In([DATA],[Time],[DATE]) " +
" Values (" + s + textBox1.Text + s + "," + s +
label2.Text + s + "," + s + label5.Text + s + ")";
//*******************
try
{
Conn.Open();
SaveInto.ExecuteNonQuery();
textBox1.Text = "";
Conn.Close();
Application.OpenForms[0].Show();
}
catch (Exception ex)
{
MessageBox.Show("Badly Entered information");وماهى الادوات التى اضيفها فى Using
يرفع من قيمة الموضوع واهمية الرد