|
-
Jun 1st, 2006, 11:23 PM
#1
Thread Starter
Hyperactive Member
[2005] Binding Radiobutton
I had a database that was designed by someone and use from the old system which in turn had many bugs.I was assigned to make a new system using this old database since all the transactions are here.Now there are two radiobutons(rbtnMale,rbtnFemale) which was suppose to be bounded to a certain field of my database table.The field Sex of the database happens to be of value 'M' and 'F', and since radiobuttons check propertty can be either true or false which can be equate to '1' or '0', I decided to have this code in my query.
SELECT PatientID,
LastName,
FirstName,
MName,
DateOfBirth,
Sex,
IIF([Sex]="M", 1, 0) as IsMale,
IIF([Sex]="F", 1, 0) as IsFemale,
SeniorCitizenID,
Address,
Phone,
Mobile,
Fax,
Email,
Guardian,
Date_Registered,
VisitDate, [Note],
Tag,
OrderTotal,
Total_Paid,
Name,
Encoder,
InDate
FROM PATIENT IIF([Sex]="M", 1, 0) as IsMale,
Executing this line makes the F and M be bounded to the two radiobuttons,but the problem arises when I had to update or make a new record.It was giving me this exception..."Duplicate output destination 'Sex' ".I know this is because of the query, can someone please show me how can I able to fix it?...thanks.
-
Jun 2nd, 2006, 01:11 AM
#2
Thread Starter
Hyperactive Member
Re: [2005] Binding Radiobutton
-
Jun 2nd, 2006, 02:01 AM
#3
Re: [2005] Binding Radiobutton
I would guess that the issue lies with your INSERT and UPDATE statements as it sounds like you might be trying to save two values to the Sex column. Your INSERT and UPDATE statements probably shouldn't even mention the IsMale and IsFemale columns. Befroe you save a record just test the values of those columns and set Sex accordingly. If you do want to mentin those columns in your SQL then it's going to require a CASE statement I would think.
Also, why are you returning integer values in the IsMale and IsFemale columns when you want to bind them to boolean properties? You should be returning True or False.
Finally, should the Sex column be boolean too? Just kidding. I know you didn't design the database but if you are able to make changes, "Gender" is a nicer word to use in that scenario don't you think? Also, it would be more proper to have a Gender table with Male and Female records and have your Patient column be a foreign key from that table.
-
Jun 2nd, 2006, 02:30 AM
#4
Thread Starter
Hyperactive Member
Re: [2005] Binding Radiobutton
I just got a good laugh at your post my friend, anyway, your right it boils down to the INSERT and UPDATE statements.This code was coded in my Fill query of my dataset designer under the command text property.Previewing the data on this part would include the IsMale and IsFemale column but not in the database itself.Perhaps you could give me some hint as to how should I have to code my UPDATE statements..I am using this one as my update code:
Me.Validate()
Me.PATIENTBindingSource1.EndEdit()
Me.PATIENTTableAdapter.Update(Me.BioPathDataSet4.PATIENT)
-
Jun 2nd, 2006, 02:40 AM
#5
Re: [2005] Binding Radiobutton
I'm afraid I haven't used the new data features of VS 2005 too much because I'm only using the Express editions at the moment and they throw a wobbly every time I try to create a Data Source. I'm guessing that you need to open your DataSet in the designer and have a look at the code that the INSERT and UPDATE statements are using. This is one of the problems with relying on auto-generated stuff: it's great when it works but when it doesn't you can be left scratching your head. Anyway, if you want some information on TableAdapters then here's the place to start: http://msdn.microsoft.com/library/de...leadapters.asp
-
Jun 2nd, 2006, 02:50 AM
#6
Thread Starter
Hyperactive Member
Re: [2005] Binding Radiobutton
Ok i understand...well, hope somebody out there could help me on this one....
-
Jun 4th, 2006, 08:13 PM
#7
Thread Starter
Hyperactive Member
Re: [2005] Binding Radiobutton
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|