Visual Studio .NET - Call and run query Visual Studio 2008

Asked By David on 05-Sep-11 04:33 PM
I have posted this many times and wonder if I am trying to do the impossible
Below is the Dataset Tableadaptor query which if you click execute the query works perfect when in Query Builder but what I am trying to do is have the option on a datagridview page to select the (Prikey3) number and run the  query with my program running this I am unable to do. to work. I need help in the way the code calls for the query and I dont have a clue what to do to make it work
I dont know if I am trying to do it the wrong way.

INSERT INTO [COURSES PLAYED]
SELECT   COURSEName, H1PAR, H2PAR, H3PAR, H4PAR, H5PAR, H6PAR, H7PAR, H8PAR, H9PAR, H10PAR, H11PAR, H12PAR, H13PAR, H14PAR, H15PAR,
      H16PAR, H17PAR, H18PAR, H1SC, H2SC, H3SC, H4SC, H5SC, H6SC, H7SC, H8SC, H9SC, H10SC, H11SC, H12SC, H13SC, H14SC, H15SC, H16SC,
      H17SC, H18SC, H1TEE, H2TEE, H3TEE, H4TEE, H5TEE, H6TEE, H7TEE, H8TEE, H9TEE, H10TEE, H11TEE, H12TEE, H13TEE, H14TEE, H15TEE,
      H16TEE, H17TEE, H18TEE, H1FWAY, H2FWAY, H3FWAY, H4FWAY, H5FWAY, H6FWAY, H7FWAY, H8FWAY, H9FWAY, H10FWAY, H11FWAY,
      H12FWAY, H13FWAY, H14FWAY, H15FWAY, H16FWAY, H17FWAY, H18FWAY, BUNK1, BUNK2, BUNK3, BUNK4, BUNK5, BUNK6, BUNK7, BUNK8,
      BUNK9, BUNK10, BUNK11, BUNK12, BUNK13, BUNK14, BUNK15, BUNK16, BUNK17, BUNK18, PUTT1, PUTT2, PUTT3, PUTT4, PUTT5, PUTT6, PUTT7,
      PUTT8, PUTT9, PUTT10, PUTT11, PUTT12, PUTT13, PUTT14, PUTT15, PUTT16, PUTT17, PUTT18, GR1, GR2, GR3, GR4, GR5, GR6, GR7, GR8, GR9,
      GR10, GR11, GR12, GR13, GR14, GR15, GR16, GR17, GR18, BUNK1OUT, BUNK2OUT, BUNK3OUT, BUNK4OUT, BUNK5OUT, BUNK6OUT, BUNK7OUT,
      BUNK8OUT, BUNK9OUT, BUNK10OUT, BUNK11OUT, BUNK12OUT, BUNK13OUT, BUNK14OUT, BUNK15OUT, BUNK16OUT, BUNK17OUT, BUNK18OUT,
     H1YDS, H2YDS, H3YDS, H4YDS, H5YDS, H6YDS, H7YDS, H8YDS, H9YDS, H10YDS, H11YDS, H12YDS, H13YDS, H14YDS, H15YDS, H16YDS,
      H17YDS, H18YDS
FROM   COURSE
WHERE   (Prikey3 = ?)

The question has been set with a bonus and I would increase this myself if it was possible to solve the problem

Thanks again I appreciate your help

David
TSN ... replied to David on 05-Sep-11 11:21 PM
hi..

in the Last line of code try to pass parameters for  (Prikey3 = ?)

something like this.....

SqlParameter sqlParam = com.Parameters.Add("@Value", SqlDbType.Int);
 

and in the Query you change this below part as shown


FROM   COURSE
WHERE   (Prikey3 =@Value)


hope this helps you...