locked
Error insert database RRS feed

  • Question

  • User-1692008722 posted

    Hello,

    I'm working at a website and yesterday I got this error when I tried to register a new user.
    Anyone knows what the problem is?

    The error is:

    Server Error in '/GIP' Application.

    Gegevenstypen komen niet overeen in criteriumexpressie.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.OleDb.OleDbException: Gegevenstypen komen niet overeen in criteriumexpressie.

    Source Error:

    Line 38:             cmdInsert.Parameters.AddWithValue("@Administrator", "False")
    Line 39: cmdInsert.Parameters.AddWithValue("@Email", txtEmail.Text)
    Line 40: cmdInsert.ExecuteNonQuery()
    Line 41: cnnRegister.Close()
    Line 42: Server.Transfer("SucRegistratie.aspx")


    Source File: C:\Users\Elien\Desktop\GIP\Registreren.aspx.vb    Line: 40

    Stack Trace:

    [OleDbException (0x80040e07): Gegevenstypen komen niet overeen in criteriumexpressie.]
    System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1070856
    System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +247
    System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +194
    System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +58
    System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +167
    System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +113
    Inloggen.btnRegistreren_Click(Object sender, EventArgs e) in C:\Users\Elien\Desktop\GIP\Registreren.aspx.vb:40
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

     this is my code:

    Imports System.IO
    Imports System.Data
    Imports System.Data.OleDb


    Partial Class Inloggen
        Inherits System.Web.UI.Page
      
        Dim cnnRegister As New OleDbConnection("provider=microsoft.jet.oledb.4.0; data source =" & Server.MapPath(".\App_Data\dbsTicketService.mdb"))
        Dim strInsert As String = "INSERT into tblKlanten (Voornaam, Familienaam, Straat, Huisnummer, Gemeente, Postcode, Gebruikersnaam, Paswoord, Administrator, Email) values(@Voornaam, @Familienaam, @Straat, @Huisnummer, @Gemeente, @Postcode, @Gebruikersnaam, @Paswoord, @Administrator, @Email)"
        Dim strselect As String = "select gebruikersnaam from tblklanten"

        Protected Sub btnRegistreren_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRegistreren.Click

            cnnRegister.Open()
            Dim ocmdUser As New OleDbCommand("SELECT gebruikersnaam FROM tblklanten", cnnRegister)
            Dim sdrUser As OleDb.OleDbDataReader
            sdrUser = ocmdUser.ExecuteReader
            Dim strUser = txtGebruikersnaam.Text
            Dim blnReader As Boolean = True
            Dim blnUniek As Boolean = True
            Do While sdrUser.Read And blnReader = True
                Dim strUserCheck As String = String.Empty
                strUserCheck = sdrUser.Item("gebruikersnaam").ToString
                If strUserCheck = strUser Then
                    blnReader = False
                    blnUniek = False
                End If
            Loop
            If blnUniek = True Then
                        Dim cmdInsert As New OleDbCommand(strInsert, cnnRegister)
                cmdInsert.Parameters.AddWithValue("@Voornaam", txtVoornaam.Text)
                cmdInsert.Parameters.AddWithValue("@Familienaam", txtAchternaam.Text)
                cmdInsert.Parameters.AddWithValue("@Straat", txtStraat.Text)
                cmdInsert.Parameters.AddWithValue("@Huisnummer", txtHuisnummer.Text)
                cmdInsert.Parameters.AddWithValue("@Gemeente", txtGemeente.Text)
                cmdInsert.Parameters.AddWithValue("@Postcode", Integer.Parse(txtPostcode.Text))
                cmdInsert.Parameters.AddWithValue("@Gebruikersnaam", txtGebruikersnaam.Text)
                cmdInsert.Parameters.AddWithValue("@Paswoord", txtPaswoord.Text)
                cmdInsert.Parameters.AddWithValue("@Administrator", "False")
                cmdInsert.Parameters.AddWithValue("@Email", txtEmail.Text)
                        cmdInsert.ExecuteNonQuery()
                cnnRegister.Close()
                Server.Transfer("SucRegistratie.aspx")
                Else
                    lblFout.Text = "deze gebruikersnaam is al in gebruik"
                End If


        End Sub

        Private Sub Leegmaken()
            'private om alle gegevens te wissen.
            txtAchternaam.Text = String.Empty
            txtEmail.Text = String.Empty
            txtVoornaam.Text = String.Empty
            txtBevestigPas.Text = String.Empty
            txtGebruikersnaam.Text = String.Empty
            txtPaswoord.Text = String.Empty
        End Sub

        Protected Sub btnAnnuleren_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAnnuleren.Click
            Call Leegmaken()
        End Sub
    End Class

     

    Thanks in advance =)

     

    Wednesday, April 13, 2011 10:54 AM

Answers

All replies