Solved

Insert Coding

Posted on 2012-03-13
4
199 Views
Last Modified: 2012-03-13
Hello Everyone,

I am getting an error message on this Insert Query and I can't find where the syntax error is.

The coding:

 Dim strQuery As String = "Insert [PersonOfInterest] ([PK_DriverLicenseID_vch], [IssuingState_vch], [Priority_vch], [FirstName_vch], [MiddleInitial_vch], [LastName_vch], [FK_Suffix_ID_vch], [PhysicalAddress1_vch], [PhysicalAddress2_vch], [PhysicalCity_vch], [FK_CountyID_vch], [FK_PhysicalState_vch], [PhysicalZip_ch], [DOBMonth-ch], [DOBDay_ch], [DOBYear_ch], [SSN1_ch], [SSN2_ch], [SSN3_ch], [FK_RaceID_vch], [HeightFt_ch], [HeightIn_ch], [FK_HairColor_vch], [FK_EyeColor_vch], [Employer_vch], [EmployerAddress_vch], [EmployerCity_vch], [EmployerState_vch], [EmployerZip_ch], [SchoolAttending_vch], [SchoolAddress_vch], [SchoolCity_vch], [SchoolState_vch], [SchoolZip_ch], [HomePhone1_ch], [HomePhone2_ch], [HomePhone3_ch], [MobilePhone1_ch], [MobilePhone2_ch], [MobilePhone3_ch], [OtherPhone1_ch], [OtherPhone2_ch], [OtherPhone3_ch], [FBINumber_vch], [Alias1_vch], [Alias2_vch], [Alias3_vch], {Alias4_vch], [Alias5_vch], [FK_IntelligenceType_vch], [ContactMonth_ch], [ContactDay_ch], [ContactYear_ch], [DateTimeAdded_vch], [UserAdded_vch], [DateTimeModified_vch], [UserModified_vch], [Weight_ch]) VALUES (@PK_DriverLicenseID_vch, @IssuingState_vch, @Priority_vch, @PhysicalCity_vch, @FK_CountyID_vch, @FK_PhysicalState_vch, @PhysicalZip_ch, @DOBMonth-ch, @DOBDay_ch], @DOBYear_ch, @SSN1_ch, @SSN2_ch, @SSN3_ch, @FK_RaceID_vch, @HeightFt_ch, @HeightIn_ch , @FK_HairColor_vch, @FK_EyeColor_vch, @Employer_vch, @EmployerAddress_vch, @EmployerCity_vch , @EmployerState_vch, @EmployerZip_ch, @SchoolAttending_vch, @SchoolAddress_vch, @SchoolCity_vch, @SchoolState_vch, @SchoolZip_ch, @HomePhone1_ch, @HomePhone2_ch, @HomePhone3_ch, @MobilePhone1_ch, @MobilePhone2_ch, @MobilePhone3_ch, @OtherPhone1_ch, @OtherPhone2_ch, @OtherPhone3_ch, @FBINumber_vch, @Alias1_vch, @Alias2_vch, @Alias3_vch, @Alias4_vch, @Alias5_vch, @FK_IntelligenceType_vch, @ContactMonth_ch, @ContactDay_ch, @ContactYear_ch, @DateTimeAdded_vch, @UserAdded_vch, @DateTimeModified_vch, @UserModified_vch, @Weight_ch); SELECT SCOPE_IDENTITY();"


IntID = Convert.ToInt32(myCommand.ExecuteScalar())


Incorrect syntax near '{'.  Error shows when the above statement is read
0
Comment
Question by:jjc9809
  • 2
4 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 37716626
The problem is that fieldname specified as {Alias4_vch] should be [Alias4_vch] inside the Insert()
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37716633
Should it not be "INSERT INTO [PersonOfInterest]..."?
0
 

Author Comment

by:jjc9809
ID: 37716916
Hi Everyone,

I am getting another error on the same coding now:

"Insert Into [PersonOfInterest] ([PK_DriverLicenseID_vch], [IssuingState_vch], [Priority_vch], [FirstName_vch], [MiddleInitial_vch], [LastName_vch], [FK_Suffix_ID_vch], [PhysicalAddress1_vch], [PhysicalAddress2_vch], [PhysicalCity_vch], [FK_CountyID_vch], [FK_PhysicalState_vch], [PhysicalZip_ch], [DOBMonth_ch], [DOBDay_ch], [DOBYear_ch], [SSN1_ch], [SSN2_ch], [SSN3_ch], [FK_RaceID_vch], [HeightFt_ch], [HeightIn_ch], [FK_HairColor_vch], [FK_EyeColor_vch], [Employer_vch], [EmployerAddress_vch], [EmployerCity_vch], [EmployerState_vch], [EmployerZip_ch], [SchoolAttending_vch], [SchoolAddress_vch], [SchoolCity_vch], [SchoolState_vch], [SchoolZip_ch], [HomePhone1_ch], [HomePhone2_ch], [HomePhone3_ch], [MobilePhone1_ch], [MobilePhone2_ch], [MobilePhone3_ch], [OtherPhone1_ch], [OtherPhone2_ch], [OtherPhone3_ch], [FBINumber_vch], [Alias1_vch], [Alias2_vch], [Alias3_vch], [Alias4_vch], [Alias5_vch], [FK_IntelligenceType_vch], [ContactMonth_ch], [ContactDay_ch], [ContactYear_ch], [DateTimeAdded_vch], [UserAdded_vch], [DateTimeModified_vch], [UserModified_vch], [Weight_ch]) VALUES (@PK_DriverLicenseID_vch, @IssuingState_vch, @Priority_vch, @PhysicalCity_vch, @FK_CountyID_vch, @FK_PhysicalState_vch, @PhysicalZip_ch, @DOBMonth_ch, @DOBDay_ch], @DOBYear_ch, @SSN1_ch, @SSN2_ch, @SSN3_ch, @FK_RaceID_vch, @HeightFt_ch, @HeightIn_ch , @FK_HairColor_vch, @FK_EyeColor_vch, @Employer_vch, @EmployerAddress_vch, @EmployerCity_vch , @EmployerState_vch, @EmployerZip_ch, @SchoolAttending_vch, @SchoolAddress_vch, @SchoolCity_vch, @SchoolState_vch, @SchoolZip_ch, @HomePhone1_ch, @HomePhone2_ch, @HomePhone3_ch, @MobilePhone1_ch, @MobilePhone2_ch, @MobilePhone3_ch, @OtherPhone1_ch, @OtherPhone2_ch, @OtherPhone3_ch, @FBINumber_vch, @Alias1_vch, @Alias2_vch, @Alias3_vch, @Alias4_vch, @Alias5_vch, @FK_IntelligenceType_vch, @ContactMonth_ch, @ContactDay_ch, @ContactYear_ch, @DateTimeAdded_vch, @UserAdded_vch, @DateTimeModified_vch, @UserModified_vch, @Weight_ch); SELECT SCOPE_IDENTITY();"


IntID = Convert.ToInt32(myCommand.ExecuteScalar())


Incorrect syntax near ']'.  Error shows when the above statement is read
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 500 total points
ID: 37716993
You have more fields than paramters..Side by side comparison here:
([PK_DriverLicenseID_vch], 		(@PK_DriverLicenseID_vch, 
 [IssuingState_vch], 		 @IssuingState_vch, 
 [Priority_vch], 		 @Priority_vch, 
 [FirstName_vch], 		 @PhysicalCity_vch, 
 [MiddleInitial_vch], 		 @FK_CountyID_vch, 
 [LastName_vch], 		 @FK_PhysicalState_vch, 
 [FK_Suffix_ID_vch], 		 @PhysicalZip_ch, 
 [PhysicalAddress1_vch], 		 @DOBMonth_ch, 
 [PhysicalAddress2_vch], 		 @DOBDay_ch], 
 [PhysicalCity_vch], 		 @DOBYear_ch, 
 [FK_CountyID_vch], 		 @SSN1_ch, 
 [FK_PhysicalState_vch], 		 @SSN2_ch, 
 [PhysicalZip_ch], 		 @SSN3_ch, 
 [DOBMonth_ch], 		 @FK_RaceID_vch, 
 [DOBDay_ch], 		 @HeightFt_ch, 
 [DOBYear_ch], 		 @HeightIn_ch , 
 [SSN1_ch], 		 @FK_HairColor_vch, 
 [SSN2_ch], 		 @FK_EyeColor_vch, 
 [SSN3_ch], 		 @Employer_vch, 
 [FK_RaceID_vch], 		 @EmployerAddress_vch, 
 [HeightFt_ch], 		 @EmployerCity_vch , 
 [HeightIn_ch], 		 @EmployerState_vch, 
 [FK_HairColor_vch], 		 @EmployerZip_ch, 
 [FK_EyeColor_vch], 		 @SchoolAttending_vch, 
 [Employer_vch], 		 @SchoolAddress_vch, 
 [EmployerAddress_vch], 		 @SchoolCity_vch, 
 [EmployerCity_vch], 		 @SchoolState_vch, 
 [EmployerState_vch], 		 @SchoolZip_ch, 
 [EmployerZip_ch], 		 @HomePhone1_ch, 
 [SchoolAttending_vch], 		 @HomePhone2_ch, 
 [SchoolAddress_vch], 		 @HomePhone3_ch, 
 [SchoolCity_vch], 		 @MobilePhone1_ch, 
 [SchoolState_vch], 		 @MobilePhone2_ch, 
 [SchoolZip_ch], 		 @MobilePhone3_ch, 
 [HomePhone1_ch], 		 @OtherPhone1_ch, 
 [HomePhone2_ch], 		 @OtherPhone2_ch, 
 [HomePhone3_ch], 		 @OtherPhone3_ch, 
 [MobilePhone1_ch], 		 @FBINumber_vch, 
 [MobilePhone2_ch], 		 @Alias1_vch, 
 [MobilePhone3_ch], 		 @Alias2_vch, 
 [OtherPhone1_ch], 		 @Alias3_vch, 
 [OtherPhone2_ch], 		 @Alias4_vch, 
 [OtherPhone3_ch], 		 @Alias5_vch, 
 [FBINumber_vch], 		 @FK_IntelligenceType_vch, 
 [Alias1_vch], 		 @ContactMonth_ch, 
 [Alias2_vch], 		 @ContactDay_ch, 
 [Alias3_vch], 		 @ContactYear_ch, 
 [Alias4_vch], 		 @DateTimeAdded_vch, 
 [Alias5_vch], 		 @UserAdded_vch, 
 [FK_IntelligenceType_vch], 		 @DateTimeModified_vch, 
 [ContactMonth_ch], 		 @UserModified_vch, 
 [ContactDay_ch], 		 @Weight_ch
 [ContactYear_ch], 		
 [DateTimeAdded_vch], 		
 [UserAdded_vch], 		
 [DateTimeModified_vch], 		
 [UserModified_vch], 		
 [Weight_ch]) 		

Open in new window


Need parameters for these
 [FirstName_vch],
 [MiddleInitial_vch],
 [LastName_vch],
 [FK_Suffix_ID_vch],
 [PhysicalAddress1_vch],
 [PhysicalAddress2_vch],
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question