转换为double类型无效

时间:2018-06-08 08:40:18

标签: sql-server vb.net winforms

我目前正在为我的数据库开发一个表单,这将允许我搜索记录,更新并在我的数据库中插入数据。

我还配置了一个代码,允许我自动将代码编号分配给我在此系统中的记录,但是当我运行表单时出现错误:

  

附加信息:从字符串转换" C000001"输入' Double'无效。"

请参阅下面的我的代码,并告知我错误的地方。

Private Sub cbName_of_School_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbName_of_School.SelectedIndexChanged
        Dim DBCon As New SqlConnection("Server=.\FGG;Database=CAOOSC_DB;User=sa;Pwd=c0nstella;")
        Dim DBCmd As SqlCommand
        Dim GetCode As String = "0"
        DBCmd = New SqlCommand
        DBCmd.Connection = DBCon
    DBCmd.CommandText = "SELECT TOP(1) * FROM tbl_Beneficiaries ORDER BY OOSC_ID DESC"

    Try
        DBCon.Open()
        Dim Reader As SqlDataReader = DBCmd.ExecuteReader(CommandBehavior.SingleRow)
        If (Reader.HasRows = True) Then
            While Reader.Read()
                GetCode = (Reader.GetString(Reader.GetOrdinal("OOSC_ID")))
            End While
        End If
        Reader.Close()

    Catch ex As Exception
        MsgBox(ex.Message)
    Finally
        DBCon.Close()

    End Try

    If (GetCode = "0") Then
        txtOOSC_ID.Text = "ZOCS_CAOOSC/OOSC000001"
    ElseIf (GetCode <> "0") Then
        Dim TotalCodeWithoutLable As String = GetCode.Count - 16
        Dim OldNum As String = GetCode.Substring(GetCode.Length - TotalCodeWithoutLable)
        txtOOSC_ID.Text = "ZOCS_CAOOSC/OOSC" + Format(OldNum + 1, "000000").ToString 'Format Number As string

    End If
End Sub`

0 个答案:

没有答案