Uniqueidentifier
-
Hello, I want to save the name of the company in the textBox2. The problem which occur is with the JobId. I will get the JobId number from a previous page as a string. Here I have quoted an example JobId. (the JobIds are saved in the database as uniqueidentifier). The Problem occurs in the ExecuteReader. I think it concerns that the parameter @JobId is of type uniqueidentifier and the the quoted jobId here is from type string. So it occurs a Data conversion failed. error. jobId = "D4DF269F-F9FB-4C88-A005-11C98B38818A"; this.dataSource = "\\Program Files\\MobileHelpDesk.sdf"; this.strConn = "Data Source = " + dataSource; this.connection = new SqlCeConnection("Data Source = " + dataSource); SqlCeCommand command = new SqlCeCommand(); command.Connection = connection; command = connection.CreateCommand(); command.CommandText = "SELECT c.CompanyName, c.ContactLName FROM Client c INNER JOIN JobDescription p ON p.EmailClient = c.Email WHERE p.JobId = ?"; command.Parameters.Add( "@JobId", jobId); connection.Open(); drdrDB = command.ExecuteReader(); while (drdrDB.Read()) { textBox2.Text = drdrDB["JobId"].ToString(); } drdrDB.Close(); connection.Close(); Does anybody know how can I solve this problem or parse the jobId string in the corresponding type?? or is there another error? But the Select String is correct, I tried it in VS.NET. thx patrick
-
Hello, I want to save the name of the company in the textBox2. The problem which occur is with the JobId. I will get the JobId number from a previous page as a string. Here I have quoted an example JobId. (the JobIds are saved in the database as uniqueidentifier). The Problem occurs in the ExecuteReader. I think it concerns that the parameter @JobId is of type uniqueidentifier and the the quoted jobId here is from type string. So it occurs a Data conversion failed. error. jobId = "D4DF269F-F9FB-4C88-A005-11C98B38818A"; this.dataSource = "\\Program Files\\MobileHelpDesk.sdf"; this.strConn = "Data Source = " + dataSource; this.connection = new SqlCeConnection("Data Source = " + dataSource); SqlCeCommand command = new SqlCeCommand(); command.Connection = connection; command = connection.CreateCommand(); command.CommandText = "SELECT c.CompanyName, c.ContactLName FROM Client c INNER JOIN JobDescription p ON p.EmailClient = c.Email WHERE p.JobId = ?"; command.Parameters.Add( "@JobId", jobId); connection.Open(); drdrDB = command.ExecuteReader(); while (drdrDB.Read()) { textBox2.Text = drdrDB["JobId"].ToString(); } drdrDB.Close(); connection.Close(); Does anybody know how can I solve this problem or parse the jobId string in the corresponding type?? or is there another error? But the Select String is correct, I tried it in VS.NET. thx patrick
The parameter value needs to be a System.Guid[^] if the SQL Server type is a uniqueidentifier. For example:
Guid jobGuid = new Guid(jobId);
command.Parameters.Add("@JobId", jobGuid);
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
-
The parameter value needs to be a System.Guid[^] if the SQL Server type is a uniqueidentifier. For example:
Guid jobGuid = new Guid(jobId);
command.Parameters.Add("@JobId", jobGuid);
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.