Private Sub Save_Record()
        Dim con As New OleDbConnection
        Dim cmd As New OleDbCommand
        Dim sSQL As String = String.Empty
        Dim arrImage() As Byte
        Dim myMs As New IO.MemoryStream
        Dim bSaveImage As Boolean = False
        Dim strImg As String = String.Empty

        If Not IsNothing(Me.pic1.Image) Then
            Me.pic1.Image.Save(myMs, Me.pic1.Image.RawFormat)
            arrImage = myMs.GetBuffer
        Else
            arrImage = Nothing
        End If
        'get connection string declared in the Module1.vb and assing it to conn variable
        con = New OleDbConnection(Get_Constring)
        con.Open()
        cmd.Connection = con
        cmd.CommandType = CommandType.Text
        'I just use the textbox tag property to idetify if the data is new or existing.
        If Me.txtFacultyFirstName.Tag = 0 Then
            sSQL = "INSERT INTO facultynew (FacultyFirstName,[FacultyLastName],[Password], [Course],[Lebel], [Address], [Image] " & _
                       "  VALUES(?,?,?,?,?,?,?)"
            cmd.CommandText = sSQL
        Else
            sSQL = "UPDATE facultynew set FacultyFirstName = @FacultyFirstName, FacultyLastName = @FacultyLastName, [Password]=[@Password], Course =  @Course, Lebel=@Lebel, Address = @Address, Image =  @Image where ID = @FacultyID"
            cmd.CommandText = sSQL
        End If


        cmd.Parameters.AddWithValue("@FacultyFirstName", OleDbType.VarChar).Value = IIf(Len(Trim(Me.txtFacultyFirstName.Text)) > 0, Me.txtFacultyFirstName.Text, DBNull.Value)
        cmd.Parameters.AddWithValue("@FacultyLastName", OleDbType.VarChar).Value = IIf(Len(Trim(Me.txtFacultyLastName.Text)) > 0, Me.txtFacultyLastName.Text, DBNull.Value)
        cmd.Parameters.AddWithValue("@Password", OleDbType.VarChar).Value = IIf(Len(Trim(Me.txtpass.Text)) > 0, Me.txtpass.Text, DBNull.Value)
        cmd.Parameters.Add("@Course", OleDbType.VarChar).Value = IIf(Len(Trim(Me.cbocourse.Text)) > 0, Me.cbocourse.Text, DBNull.Value)
        cmd.Parameters.Add("@Lebel", OleDbType.VarChar).Value = IIf(Len(Trim(Me.cbolebel.Text)) > 0, Me.cbolebel.Text, DBNull.Value)
        cmd.Parameters.Add("@Address", OleDbType.VarChar).Value = IIf(Len(Trim(Me.txtaddress.Text)) > 0, Me.txtaddress.Text, DBNull.Value)
        ' cmd.Parameters.Add("@Lebel", OleDbType.VarChar).Value = IIf(Len(Trim(Me.cbolebel.Text)) > 0, Me.cbolebel.Text, DBNull.Value)
        cmd.Parameters.Add("@Image", OleDbType.Binary).Value = IIf(Not IsNothing(arrImage), arrImage, DBNull.Value)

        cmd.ExecuteNonQuery()

        'If the record is new then we have to get its ID so that we can edit it rightaway after the insertion.
        If Me.txtFacultyFirstName.Tag = 0 Then
            cmd.CommandText = "Select @@Identity"
            'Set textbox tag property with the ID of new record
            Me.txtFacultyFirstName.Tag = cmd.ExecuteScalar()
        End If
        MsgBox("Data has been save.")
        ' Catch ex As Exception
        'MsgBox(ErrorToString)
        'Finally


        con.Close()
        'End Try

Cant find the error:((

What line does Visual Studio tell you it's on when you run it?

cmd.executenonquery

tnx bros i finally see it.,.,it line 23 )

One thing that's incorrect is that you need a ) after [Image] in your INSERT INTO statement

No value given for one or more required parameters

on my cmd.executenonquery

if i update data in database

Check through all your parameter values, as one of them seems to be blank. Also, I don't know if it is significant, but on line 34, @Password is not wrapped in [ ] whereas on line 27 it is.

i cant find blank sir.,.,because facultyid are autonumber

How can I fix a Javascript Application syntax error on Firefox Nightly?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.