borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Inserting a banner...)Next Topic (i wish to do a animation in the top part of a form.) New Topic New Poll Post Reply
AndreaVB Forum : ASP.Net : Urgent Help Needed
Poster Message
Anelore
Level: Trainee

Registered: 01-02-2006
Posts: 2

icon Urgent Help Needed

I have a little online form that accepts an employee's first and last name and their selection of a class time from a dropdown.
On submit, the form adds a new record to the "employee" table with the employee first and last name and then updates the "classList" table, adding one to the number of students registered to the class selected (since each class can only have 25 students). It is an Access 2003 database.
The problem is the database hangs up. Somewhere in my code, I am not properly closing the connection. Needless to say, when enough people hit the database, it causes big problems on the server.
I really need help!! Thanks in advance.
Here is my code:
If Page.IsValid Then
        Dim objConn As New OleDbConnection(sConnStr)
        Dim strFName, strLName As String
        Dim intID As Integer

        strFName = txtFName.Text
        strLName = txtLName.Text
        intID = ddlClasses.SelectedItem.Value
        Dim clID As New OleDbParameter("@clID", OleDbType.Integer)
        clID.Value = intID

        strSQL = New System.Text.StringBuilder()

        strSQL.Append("INSERT INTO employees (FName, LName, Class_ID) VALUES ('" & txtFName.Text & "','" & txtLName.Text & "', '" & intID & "' )")
        Dim objCommand As New OleDbCommand(strSQL.ToString, objConn)
        objConn.Open()

        objCommand.ExecuteNonQuery()

        strSQL = New System.Text.StringBuilder()
        strSQL.Append("UPDATE classList SET studentCt = studentCt + 1 WHERE Class_ID = " & intID & " ")
        objCommand = New OleDbCommand(strSQL.ToString, objConn)
        lblTest.Text = strSQL.ToString
        objCommand.ExecuteNonQuery()
        objConn.Close()
        objConn = Nothing

        lblThanks.Visible = True
        btnSubmit.Visible = False

      End If

01-02-2006 at 02:41 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: Urgent Help Needed

Hi,
Can you be a bit more specific as to which line of code causes the exception. Try stepping through the code to see which line throws you out.
Just as a quick thought though, you have put single quotes around 'intID' in the INSERT INTO string. This could be causing a problem when the database is expecting an Integer Value for the Field, not a String.


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

01-02-2006 at 03:15 PM
View Profile Send Email to User Show All Posts | Quote Reply
Anelore
Level: Trainee

Registered: 01-02-2006
Posts: 2
icon Re: Urgent Help Needed

Never mind! I found the problem in another part of the code

01-02-2006 at 03:26 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : ASP.Net : Urgent Help Needed
Previous Topic (Inserting a banner...)Next Topic (i wish to do a animation in the top part of a form.) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder