Solved

Insert Error Still

Posted on 2012-03-13
2
207 Views
Last Modified: 2012-03-16
I have an error when the Insert is read:

My coding:  Dim strQuery As String = "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, @FirstName_vch, @MiddleInitial_vch, @LastName_vch, @FK_Suffix_ID_vch, @PhysicalAddress1_vch, @PhysicalAddress2_vch, @DateTimeAdded_vch, @UserAdded_vch, @DateTimeModified_vch, @UserModified_vch, @Weight_ch); SELECT SCOPE_IDENTITY();"


The error appears on this coding and stops:

'Open the connection
        myConnection.Open()

        'Execute the query
        IntID = Convert.ToInt32(myCommand.ExecuteScalar())

        'Brings the ID Field in
        Me.ID.Text = IntID
        QueryResult.Text = "Record '" + IntID.ToString() + "' was saved successfully!"


There is an incorrect syntax on "]"

I can't see the problem.

jjc9809
0
Comment
Question by:jjc9809
  • 2
2 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 500 total points
ID: 37717253
Here is the side by side again:

[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], 		 @FirstName_vch, 
 [Alias5_vch], 		 @MiddleInitial_vch, 
 [FK_IntelligenceType_vch], 		 @LastName_vch, 
 [ContactMonth_ch], 		 @FK_Suffix_ID_vch, 
 [ContactDay_ch], 		 @PhysicalAddress1_vch, 
 [ContactYear_ch], 		 @PhysicalAddress2_vch, 
 [DateTimeAdded_vch], 		 @DateTimeAdded_vch, 
 [UserAdded_vch], 		 @UserAdded_vch, 
 [DateTimeModified_vch], 		 @DateTimeModified_vch, 
 [UserModified_vch], 		 @UserModified_vch, 
 [Weight_ch]		 @Weight_ch

Open in new window


Note that the order of parameters must match the order of your fields

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

Open in new window

0
 
LVL 38

Expert Comment

by:PaulHews
ID: 37721903
Here it is in original format:

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

Open in new window

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WPF - Tooltips for ComboBox items 5 67
Help with LINQ and XML 10 35
Exit the loop 4 42
How to sort a list of objects using an item in an enclosed list 5 46
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

815 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now