none
it showing error "number & destination fields are not same"i have 1 combobox on my form for list of subjcts,checklistbox for rool no of student,datetimepicker,and 2 buttons "save","exit"in my database i have fields studid,date,subject,attendenc-checkbox RRS feed

  • Question

  • Imports System.Data
    Imports System.Data.SqlClient
    Public Class SY
    
        Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim no As String = ComboBox1.Text
            Dim tit As String = CheckedListBox1.Text
    
    
            Dim conn As New OleDb.OleDbConnection
            Dim cmd As New OleDb.OleDbCommand
    
            Dim StrQuary As String
    
            conn = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Gaurav\Desktop\New folder\Attendence  System.mdb")
            StrQuary = "insert into Table102 values('" & ComboBox1.Text & "','" & CheckedListBox1.Text & "','" & DateTimePicker1.Value & "')"
    
            Try
                conn.Open()
                cmd = New OleDb.OleDbCommand(StrQuary, conn)
                cmd.ExecuteNonQuery()
                MsgBox("RECORD IS SAVE!")
                conn.Close()
    
    
            Catch ex As Exception
    
                MsgBox(ex.Message)
    
            End Try
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Me.Close()
    
        End Sub
    

    Sunday, March 18, 2012 7:55 AM

All replies

  • Hi hgxcv,

    Welcome to MSDN Forum.

    Please try to add a break point at the line of StrQuery, then get the actual T-SQL, execute it in the database directly to make sure whether the T-SQL is correct.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, March 19, 2012 8:21 AM
    Moderator
  • Hi hgxcv,

    Have you solved the issue? If you have any problems, please feel free to let me know.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, March 21, 2012 2:39 AM
    Moderator