Link to home
Start Free TrialLog in
Avatar of kwh3856
kwh3856Flag for United States of America

asked on

Format of the initialization string does not conform to specficiation starting at index 46

I am trying to open an SQL database and write a record.  Here is the error message I am getting.

An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll

Additional information: Format of the initialization string does not conform to specification starting at index 46.


Here is the code.

'Get Math Objective Info

            Dim m As Int32
            Dim midx As Integer = 1
            Dim mathObjNumbersArray(60) As String
            For m = 1 To 101 Step 2
                mathObjNumbersArray(midx) = Mid(mathObjNumbers, m, 2)
                midx += 1
            Next

            Dim m1 As Int32
            Dim midx2 As Integer = 1
            Dim mathItemCorrectRespArray(60) As String
            For m1 = 1 To 101 Step 2
                mathItemCorrectRespArray(midx2) = Mid(mathItemCorrectResp, m1, 1)
                midx2 += 1
            Next

            Dim m2 As Int32
            Dim midx3 As Integer = 1
            Dim mathStudentRespArray(60) As String
            For m2 = 1 To 101 Step 2
                mathStudentRespArray(midx3) = Mid(mathStudentResp, m2, 2)
                midx3 += 1
            Next
            Try
                'Write Math Objective Info record
                Dim objConnection2 As SqlConnection = New SqlConnection("server=(local);database=FBISK-TAKS;user id=sa;password=""")    
                Dim objCommand2 As SqlCommand = New SqlCommand
                objCommand2.Connection = objConnection2

                Dim m4 As Int32
                For m4 = 1 To 60
                    objCommand2.CommandText = "Insert Into itemAnalysisDetail " _
                                & "(admDate, studentId, teacherId, objectiveNumber, itemCorrectResp, studentResp) " & _
                                "VALUES(@admDate, @studentId, @teacherId, @mathobj(m4), @mathItemCorrectRespArray(m4), @mathStudentRespArray(m4))"
                    objConnection2.Open()
                    objCommand2.ExecuteNonQuery()
                    objConnection2.Close()
                Next

            Catch ex As Exception
                MsgBox(ex.Message)

            End Try



Any help is greatly appreciated..

Thanks
Kenny

Avatar of kwh3856
kwh3856
Flag of United States of America image

ASKER

My for next loop was set to 101.  I tried changing it to 30 but I still have the same problem
SOLUTION
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kwh3856

ASKER

Thanks to both of you very much....this was driving me nuts since I am new to VB.  


Thanks
Kenny