Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem:- Vb.net connectivity is Ok and the data from SQL is accessingcorrectly

ID: 3613508 • Letter: P

Question

Problem:-
Vb.net connectivity is Ok and the data from SQL is accessingcorrectly but when i insert, delete and update then data notinserted in tables. Code and the eroor message is under so pleasecheck it and after that reply me the solution of this error.
Thanks.


Public Class Form1
    Dim con As New ADODB.Connection()
    Dim rs As New ADODB.Recordset()

    Private Sub Form1_Leave(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.Leave
        rs.Close()
        con.Close()
    End Sub
    Private Sub Form1_Load(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        con.ConnectionString ="Driver={Microsoft ODBC for Oracle};" & _
       "UID=Admin;PWD=Admin"
        con.Open()

        rs.Open("Select * fromcategory", con, ADODB.CursorTypeEnum.adOpenDynamic)
        populate()
    End Sub

    Sub populate()
        With rs
           txtid.Text = .Fields(0).Value
           txtname.Text = .Fields(1).Value

        End With

    End Sub

    Private Sub btnnext_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesbtnnext.Click
        rs.MoveNext()

        If rs.EOF Then
           rs.MoveFirst()
           populate()
        Else
           populate()
        End If
    End Sub

    Private Sub btnlast_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesbtnlast.Click
        rs.MoveLast()
        populate()
    End Sub

    Private Sub btnfirst_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesbtnfirst.Click
        rs.MoveFirst()
        populate()
    End Sub

    Private Sub btnprevious_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesbtnprevious.Click
        rs.MovePrevious()

        If rs.BOF Then
           rs.MoveLast()
           populate()
        Else
           populate()
        End If
    End Sub

    Private Sub btnclear_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesbtnclear.Click
        txtid.Text = ""
        txtname.Text = ""
    End Sub

    Private Sub btnadd_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesbtnadd.Click
        addition()
    End Sub

    Sub addition()
        'Try

***************************** Error in Query

        con.Execute("insert intocategory values(" & CInt(txtid.Text) & ",'" &txtname.Text & "');")
      
********************************Error name
[Microsoft][ODBC driver for Oracle][Oracle]ORA-00911: invalidcharacter
****************************************************

Explanation / Answer

Ditch your semicolon. con.Execute("insert into category values(" & CInt(txtid.Text)& ",'" & txtname.Text & "')")

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote