Я получаю сообщение об ошибке «Неопознанный формат Guid» - PullRequest
1 голос
/ 06 января 2011
Public Function GetPrinter(ByVal PrinterID As Guid) As DataSet
    Try
        GetPrinter = New DataSet
        MyBase.SQL = "SelectPrinter"
        //Initialize the Command object
        MyBase.InitializeCommand()
        //Add the Parameter to the Parameters collection
        MyBase.AddParameter("@PrinterID", _
            SqlDbType.UniqueIdentifier, 16, PrinterID)
        //Fill the DataSet
        MyBase.FillDataSet(GetPrinter, "Printers")
    Catch ExceptionErr As Exception
        Throw New System.Exception(ExceptionErr.Message, _
            ExceptionErr.InnerException)
    End Try
End Function


Public Function GetPrinter(ByVal PrinterID As Guid) As DataSet
    Try
        //Call the data component to get a specific Printer
        GetPrinter = objPrinterDA.GetPrinter(PrinterID)
    Catch ExceptionErr As Exception
        Throw New System.Exception(ExceptionErr.Message, _
            ExceptionErr.InnerException)
    End Try
End Function


Private Sub cboCodeLevelPrinters_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboCodeLevelPrinters.SelectedIndexChanged
    //Initialize a new instance of the business logic component
    Using objPrinters As New CodeLevelsBusinessLogic.PrintersBL( _
        strCompany, strApplication)
        Try

 //The next line of code throws a "Unrecognozed Guid Format" error message.
            //Get the specific Printer selected in the cboCodeLevelPrinters combobox
            objDataSet = objPrinters.GetPrinter( _
                New Guid(cboCodeLevelPrinters.SelectedText.ToString.ToUpper))
 //End error line

            //Populate the CodeLevels Location & IPAddress textbox's
            txtCodeLevelLocation.Text = ( _
                objDataSet.Tables("Printers").Rows(0).Item("PrinterLocation"))
            txtCodeLevelIPAddress.Text = ( _
                objDataSet.Tables("Printers").Rows(0).Item("PrinterIPAddress"))
        Catch ExceptionErr As Exception
            MessageBox.Show(ExceptionErr.Message, strAppTitle)
        End Try
    End Using
End Sub

1 Ответ

0 голосов
/ 06 января 2011

Формат строки конструктора Guid должен быть в одном из следующих форматов ( Документация MSDN )

dddddddddddddddddddddddddddddddd

-or-

ддддддд-дддд-дддд-дддд-дддддддддд

-или-

{ддддддд-дддд-дддд-дддд-ддддддддддд *

-или-

(dddddddd-dddd-dddd-dddd-dddddddddddd)

-or-

{0xdddddddd, 0xdddd, 0xdddd, {0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0x}}

Убедитесь, что значение, полученное из комбинированного списка, имеет один из этих форматов.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...