2011-01-06 73 views
1
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 

回答

0

的GUID构造函数的字符串格式必须是以下格式之一(MSDN documentation

dddddddddddddddddddddddddddddddd

- 或 -

dddddddddddd-DDDDDDDD-dddddddddddd

- 或 -

{dddddddddddd-DDDDDDDD-dddddddddddd}

- 或 -

(dddddddddddd-DDDDDDDD-dddddddddddd)

- 或 -

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

确保您从组合框中获得的值是以下格式之一。

相关问题