Community discussion forum

General Exception occurs

Tags:
  • 7 months ago

    pls someone help me in my coding general exception occurs each time.

    Exception is :Format of the initialization string does not conform to specification starting at index 0.

    What does it means???

    <vb> 

       Private Sub cmdok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdok.Click

            If txtnew.Text = "" Or txtconform.Text = "" Or txtold.Text = "" Then
                MsgBox("Fill data into every field", MsgBoxStyle.Exclamation, "Null data Field")
            End If

            If txtnew.Text = txtconform.Text Then
                Try
                    strsql = "UPDATE login SET Password= '" & txtnew.Text & "' WHERE Password = '" & txtold.Text & "' "
                    cnsql = New OleDbConnection(strsql)
                    cnsql.Open()

                    cmsql = New OleDbCommand(strsql, cnsql)
                    cnsql.Close()
                    cmsql.Dispose()
                    cnsql.Dispose()
                Catch ex As OleDbException
                    MsgBox(ex.Message, MsgBoxStyle.Critical, "Oledb error")
                Catch exp As Exception
                    MsgBox(exp.Message, MsgBoxStyle.Critical, "General")
                End Try

     </vb>

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 6 months ago

     That's probably because you tried to use the sql string as the connection string

    Try
                   strsql = "UPDATE login SET Password= '" & txtnew.Text & "' WHERE Password = '" & txtold.Text & "' "
                    cnstr = "server=DBSERVER;User id=USER;password=PASSWORD;database=DB"
                    cnsql = New OleDbConnection(cnstr)

                    cnsql.Open()

                    cmsql = New OleDbCommand(strsql, cnsql)
                    cnsql.Close()
                    cmsql.Dispose()
                    cnsql.Dispose()
                Catch ex As OleDbException
                    MsgBox(ex.Message, MsgBoxStyle.Critical, "Oledb error")
                Catch exp As Exception
                    MsgBox(exp.Message, MsgBoxStyle.Critical, "General")
                End Try

    A great resource for connection strings: http://www.connectionstrings.com/

     

     

Post a reply

Enter your message below

Sign in or Join us (it's free).