Parameter Help

  • Thread starter Thread starter Stephen Lynch
  • Start date Start date
S

Stephen Lynch

I have a dropdown box called EmployeeUID. How do I reference it for the
parameter value?

Here are my lines, The problem is parameterEmployeeUID.Value =
this.EmployeeUID.Text;

Do I convert it to text, if so how?

OleDbParameter parameterEmployeeUID = new OleDbParameter("@EmployeeUID",
OleDbType.Guid, 16);
parameterEmployeeUID.Value = this.EmployeeUID.Text;
myCommand.Parameters.Add(parameterEmployeeUID);


Thanks in advance
 
If you bind the actual value to the dropdown (the ID) and have the text as
another field, you simply reference

new Guid(this.EmployeeUID.SelectedValue)

If you do .Text, it selects the actual text current displayed in teh drop
down. If you are displaying GUIDs (yuck!), that is okay, but you should
still cast as a Guid (at minimum) or as the proper SqlType (preferable)
rather than attempting to bind a string to a Guid value.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
 
Ok, again, what exception is being thrown?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Bill:

I got it working by changing the Type from Guid to Char.

OleDbParameter parameterEmployeeUID = new OleDbParameter("@EmployeeUID",
OleDbType.Char, 16);
 
Yes, but if it is a Guid, you are better to cast the value as a Guid than to
switch to char. Also, a char(16) is WAY too short to hold the Guid, so you
are likely truncating off values you need.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
 
Back
Top