Im writing a script for my ASP.NET project and I have ran into quite a strange problem. Basically I want to be able to create a page that allows someone to add a student to the database. They enter in the following:
Student Number: (this is unique but not an autonumber)
Name:
Course:
The script then takes the student ID and compares it with the existing database and acts accordingly. This works fine for both scenarios.
I have also implemented some Required Field Validator controls on the textboxes so if they omit say the student number, they will be told accordingly.
My problem is that testing the software on my local machine works just as I want it however when I upload it to my webspace I get the following:
Also say if I enter the student number, the name but miss out the course the field validators do not work and it creates the database entry. Anyone has anything like this before? for reference here is my code that the webspace falls over on:
When the button to submit a student is clicked this method is invoked
The method then checks the id against the database
I am using Visual Studio 2005 but I doubt that would be the problem, anyone else got any ideas as I can't see it myself?
Thanks in advance
Student Number: (this is unique but not an autonumber)
Name:
Course:
The script then takes the student ID and compares it with the existing database and acts accordingly. This works fine for both scenarios.
I have also implemented some Required Field Validator controls on the textboxes so if they omit say the student number, they will be told accordingly.
My problem is that testing the software on my local machine works just as I want it however when I upload it to my webspace I get the following:
Code:
System.FormatException: Input string was not in a correct format.
Also say if I enter the student number, the name but miss out the course the field validators do not work and it creates the database entry. Anyone has anything like this before? for reference here is my code that the webspace falls over on:
When the button to submit a student is clicked this method is invoked
Code:
Sub processValidation(ByVal s As Object, ByVal e As EventArgs)
Dim studentID As String
studentID = Convert.ToInt32(txtStudentID.Text)
Dim studentCheck As New System.Data.DataSet
error occurs here --> studentCheck = validateStudent(studentID)
If studentCheck.Tables(0).Rows.Count = 1 Then
lblError.Text = ("This student is already enrolled")
Else
addStudent()
End If
End Sub
The method then checks the id against the database
Code:
Function validateStudent(ByVal studentID As Integer) As System.Data.DataSet
Dim queryString As String = "SELECT [STUDENT].[studentID] FROM [STUDENT] WHERE ([STUDENT].[studentID] = @stude" & _
"ntID)"
objCmd = New OleDbCommand
objCmd.CommandText = queryString
objCmd.Connection = objConn
Dim dbParam_studentID As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_studentID.ParameterName = "@studentID"
dbParam_studentID.Value = txtStudentID.Text
dbParam_studentID.DbType = System.Data.DbType.Int32
objCmd.Parameters.Add(dbParam_studentID)
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = objCmd
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
I am using Visual Studio 2005 but I doubt that would be the problem, anyone else got any ideas as I can't see it myself?
Thanks in advance