منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : (سؤال؟)كود اضافة التاريخ في قاعدة البيانات
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
بسم الله الرحمن الرحيم 
اريد كود اضافة التاريخ في قاعدة البيانات 
انا كتبت هذا الكود ولكن لم يتم الاضافة .. هل يوجد خطأ في الكود ؟
كود :
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
       ''datt.Text = DateTimePicker1.Text
       If (TextBox2.Text = "" Or TextBox4.Text = "" Or RichTextBox1.Text = "") Then
           MsgBox(" ?↔?اكمل بياناتك")
       Else
           tafel1 = 1
           Try
               con.Open()
               com.Connection = con
               com.CommandText = "insert into sect1 (sect_numb,sect_name,data_sect,tafell,data_tafell,nots) values ( " & TextBox2.Text & ",'" & TextBox4.Text & "', " & DateTimePicker1.Text & " ," & tafel1.ToString & ", " & DateTimePicker2.Text & " ,'" & RichTextBox1.Text & "')"
               ' com.CommandText = "insert into sect1 values(" & TextBox2.Text & ",'" & TextBox4.Text & "','" & DateTimePicker1.ToString & "'," & tafel1 & ",'" & DateTimePicker2.ToString & "','" & RichTextBox1.Text & "')"
               com.ExecuteNonQuery()
               MsgBox("تم التسجيل بنجاح")

               ds.Reset()
               Dim sql4 As String = "select *from sect1 "
               Dim da As New SqlDataAdapter(sql4, con)
               da.Fill(ds, "sect1")
               DataGridView1.DataSource = ds.Tables(0)
           Catch ex As Exception
               MsgBox(ex.Message)
               MsgBox("لم يتم التسجيل")
           Finally
               con.Close()
           End Try
       End If
   End Sub
تم التعديل في هذا الجزء
مع بعض الترتيب
جرب الان
كود :
com.Connection = con
               com.CommandType = CommandType.Text
               com.CommandText = "insert into sect1 (sect_numb,sect_name,data_sect,tafell,data_tafell,nots) values ( '" & TextBox2.Text &
                   "','" & TextBox4.Text &
                   "','" & DateTimePicker1.Value &
                   "','" & tafel1.ToString &
                   "','" & DateTimePicker2.Value &
                   "','" & RichTextBox1.Text & "')"
               com.ExecuteNonQuery()