Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

After nearly 2 years of same code, a problem

Status
Not open for further replies.

vogue1

Programmer
Nov 13, 2004
6
US
I have a program that I have been using for nearly 2 years now. It takes the scores of college basketball games and writes them to a table. I do the grading for each day's activity the following day.

The past 2 Sundays have been terrible. There are over 100 games on Saturday to grade and for some reason it is not writing the scores there.

Now the first Sunday, I closed my Mozilla browser then put all the scores in using my IE and it worked. That is a lot of extra work because it takes about 20 minutes to get them entered.

Then last Sunday it did the same thing. I switched browsers(not knowing why it worked the Sunday before) but this time it didn't work. By the way, the code works the following way. I enter the scores of all the games and it is programmed to check the target table for all the games my various members have selected.

I thought at first it may be that I am using a session variable and perhaps more than 100 games is causing my problem. But remember it did work once by switching browsers. So I am really lost here.

Below is the code for what I am using. Once procedure obtains the session variable to use in the other procedure that does the actual "grading".

Any help, thanks.

Sub GradeCBB ()
Dim ind As Short
Dim sbcount As Short = Session("CBBCount")
Dim myArray(sbcount,4) As Short
For ind = 1 To sbcount
myArray(ind - 1,0) = CShort(CType(DataGrid1.Items(ind - 1).FindControl("Label1"), Label).Text)

'Label1.Text = CShort(CType(DataGrid1.Items(ind - 1).FindControl("DropDownList1"), DropDownList).SelectedItem.Text & _
' CType(DataGrid1.Items(ind - 1).FindControl("DropDownList2"), DropDownList).SelectedItem.Text)
' exit sub

myArray(ind - 1,1) = CShort(CType(DataGrid1.Items(ind - 1).FindControl("DropDownList1"), DropDownList).SelectedItem.Text & _
CType(DataGrid1.Items(ind - 1).FindControl("DropDownList2"), DropDownList).SelectedItem.Text)
myArray(ind - 1,2) = CShort(CType(DataGrid1.Items(ind - 1).FindControl("DropDownList3"), DropDownList).SelectedItem.Text & _
CType(DataGrid1.Items(ind - 1).FindControl("DropDownList4"), DropDownList).SelectedItem.Text)
myArray(ind - 1,3) = CShort(CType(DataGrid1.Items(ind - 1).FindControl("DropDownList5"), DropDownList).SelectedItem.Text)
' Next
If myArray(ind - 1,1) = 0 AND myArray(ind - 1,2) = 0 AND myArray(ind - 1,3) = 0 Then
Label1.Text = "You have an invalid entry."
EXIT SUB
End If
If (myArray(ind - 1,1) > 0 OR myArray(ind - 1,2) > 0) AND myArray(ind -1,3) = 1 Then
Label1.Text = "You have an invalid entry."
EXIT SUB
End IF
Next
For ind = 1 To Session("CBBCount")
Dim Var1,Var2,Var3,var4 As Short
var1 = myArray(ind - 1,0)
var2 = myArray(ind - 1,1)
var3 = myArray(ind - 1,2)
var4 = myArray(ind - 1,3)
Dim connString As String
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("connString"))
sqlConnection.Open()
Dim cmd As New SqlCommand("CBBProc", sqlConnection)
cmd.Commandtype = Commandtype.StoredProcedure
Dim param1 As New SqlParameter("@Var1", SqlDBType.SmallInt)
param1.Direction = ParameterDirection.Input
param1.Value = Var1
cmd.Parameters.Add(param1)
Dim param2 As New SqlParameter("@Var2", SqlDBType.SmallInt)
param2.Direction = ParameterDirection.Input
param2.Value = Var2
cmd.Parameters.Add(param2)
Dim param3 As New SqlParameter("@Var3", SqlDBType.SmallInt)
param3.Direction = ParameterDirection.Input
param3.Value = Var3
cmd.Parameters.Add(param3)
Dim param4 As New SqlParameter("@Var4", SqlDBType.SmallInt)
param4.Direction = ParameterDirection.Input
param4.Value = Var4
cmd.Parameters.Add(param4)
cmd.ExecuteNonQuery()
sqlConnection.Close()
Next

End Sub

Above is the main proc. below is the function to get the session variable.

Function CBBCheck() As System.Data.DataSet
Session("CBBCount") = 0
Dim connectionString As String
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("connString"))
Dim queryString As String = "CBBSelect10"
Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
Dim dataAdapter As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter(sqlCommand)
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Session("CBBCount") = dataSet.Tables(0).rows.count
Return dataSet
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top