الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

دالة Add, Update,find,delete

بدأه مخالف_66 في 10 يوليو 2008 · 2 رد · 966 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته اذا ممكن توضحون لي وين المشكلة ما تشتغل الدوال

وطول الوقت عندة مشكلة في &

وكمان في SQLLabel

تحلون لي المشكلة

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

وعملت الربط مع الاكسيس بدون اكواد

  
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Try
            OleDbConnection1.Open()
            Dim command As String

            'set up an SQL delete
            command = "delete from EMPLOYEES where EMPLOYEES =" & "values(" & IDTextBox.Text & "," & No_careerTextBox.Text & ",'" & Name_empTextBox.Text & "' , '" & JopTextBox.Text & "' , '" & AgeTextBox.Text & "' , '" & NationalityTextBox.Text & "' , '" & Marital_statusTextBox.Text & "' , '" & EducationTextBox.Text & "' , '" & Exp_on_computerTextBox.Text & "' , " & SalaryTextBox.Text & " , " & Work_hoursTextBox.Text & " , '" & VacationTextBox.Text & "' , '" & Work_DepTextBox.Text & "' , '" & Years_of_workTextBox.Text & "';"
            OleDbDataAdapter1.DeleteCommand.CommandText = command
            SQLLabel.Text = command

            'do the delete
            OleDbDataAdapter1.DeleteCommand.ExecuteNonQuery()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            OleDbConnection1.Close()
        End Try

    End Sub






 Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        Try
            OleDbConnection1.Open()
            Dim command As String

            'set up an SQL delete
            command = "update EMPLOYEES set ID =" & "values(" & IDTextBox.Text & "," & No_careerTextBox.Text & ",'" & Name_empTextBox.Text & "' , '" & JopTextBox.Text & "' , '" & AgeTextBox.Text & "' , '" & NationalityTextBox.Text & "' , '" & Marital_statusTextBox.Text & "' , '" & EducationTextBox.Text & "' , '" & Exp_on_computerTextBox.Text & "' , " & SalaryTextBox.Text & " , " & Work_hoursTextBox.Text & " , '" & VacationTextBox.Text & "' , '" & Work_DepTextBox.Text & "' , '" & Years_of_workTextBox.Text & "';"
            OleDbDataAdapter1.DeleteCommand.CommandText = command
            SQLLabel.Text = command

            'do the delete
            OleDbDataAdapter1.DeleteCommand.ExecuteNonQuery()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            OleDbConnection1.Close()
        End Try
    End Sub
End Class











  Try

              OleDbConnection1.Open()

              '  Dim SQL As String

              Dim command As String

              'set up an SQL insert

              command = "insert into EMPLOYEES(ID,No_career,Name emp,Jop,Age,Nationality,Marital status,Education,Exp_on_ computer,Salary,Work hours,Vacation,Work_Dep,Years_of_work)"

  " & "values(" & IDTextBox.Text & " , " & No_careerTextBox.Text & " , '" & Name empTextBox.Text & "' , '" & JopTextBox.Text & "' , " & AgeTextBox.Text & ",'" & NationalityTextBox.Text & "','" & Marital statusTextBox.Text & "','" & EducationTextBox.Text & "','" & Exp_on_ computerTextBox.Text & " , '" & SalaryTextBox.Text & "' , " & Work hoursTextBox.Text & " ,'" & VacationTextBox.Text & "','" & Work_DepTextBox.Text & "','" & Years_of_workTextBox.Text & "',  )"

              OleDbDataAdapter1.InsertCommand.CommandText = command

              Label2.Text = command



              'do the insert

              OleDbDataAdapter1.InsertCommand.ExecuteNonQuery()

          Catch ex As Exception

              MessageBox.Show(ex.Message)

          Finally

              OleDbConnection1.Close()

          End Try

  ________________________________________________________







  ' Try

          'Dim table As New DataTable()

          Dim command As String

          Dim recoredcount As Integer

          'set up an sql query

          command = "select* from EMPLOYEES wher"

              &"ID=" & "'" &



  ID,No_career,Name emp,Jop,Age,Nationality,Marital status,Education,Exp_on_ computer,Salary,Work hours,Vacation,Work_Dep,Years_of_work)"



  OleDbDataAdapter1.SelectCommand.CommandText = command SQLLable.Text = command

          'do the query

          EMPLOYEES.Cleary()

          recordCount = OleDbDataAdapter1.Fill(EMPLOYEES)

  display any result 

          If recordcount <> 0 Then

              Name(empBox.Text = CStr(EMPLOYEES(0)(1)))



          Else

              MessageBox.Show("not found ")

          End If

          Catch ex As Exception

              MessageBox.Show(ex.Message)



          End Try
#2

السلام عليكم

المشكلة عندك في جمل الاستعلامات فمثلا Update & delete لا تأخذ Values وانما على الصيغة

where Id= 5 and name='123'

لذا عليك بمراجعة اساسيات الاستعلامات او استخدام معالجات الاكسس لبناء هذه الاستعلامات

#3

تفضل كلاس جاهز من الجماعة في Codeprojec للتعامل مع الداتا بيس

http://www.codeproject.com/KB/database/atcl.aspx

مواضيع مشابهة