Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-28-2005, 03:37 AM   PM User | #1
AlexClifford
New to the CF scene

 
Join Date: Jan 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
AlexClifford is an unknown quantity at this point
INSERT INTO Clause problem

Hi,

I have a function for inserting new data into a table but I'm receiving the following error:

Code:
Server Error in '/Contractors' Application.
Insert Error: Column name or number of supplied values does not match table definition.
Description: An unhandled exception occurred during the execution of the current web 
request. Please review the stack trace for more information about the error and where 
it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Insert Error: Column 
name or number of supplied values does not match table definition.

Source Error:

An unhandled exception was generated during the execution of the current web request. 
Information regarding the origin and location of the exception can be identified using 
the exception stack trace below.
The table conists of the following columns, they are all type char, expect ID is type int:
ID
VendorNo
DateIssued
FirstName
Surname
ContactNumber
Address

I'm not completely sure if I'm supposed to use the Param's for INSERT INTO clause, but here is the function I'm calling thats causing the error:

Code:
Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
    'Save the values from the details fields to the database
    conn.Open()
    Try
        Dim updAdd As SqlCommand = New SqlCommand("INSERT INTO Contacts VALUES (@VendorNo, @DateIssued, @Surname, @FirstName, @ContactNumber, @Address)", conn)
        With updAdd.Parameters
            .Add("@VendorNo", txtAddVendorNumber.Text)
            .Add("@DateIssued", txtAddDateIssued.Text)
            .Add("@Surname", txtAddSurname.Text)
            .Add("@FirstName", txtAddFirstName.Text)
            .Add("@ContactNumber", txtAddContactNumber.Text)
            .Add("@Address", txtAddAddress.Text)
        End With
        updAdd.ExecuteNonQuery()
    Finally
        conn.Close()
    End Try
End Sub
Any help solving this issue would be greatly appreciated! It's got me confused thats for sure heh.
AlexClifford is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:33 AM.


Advertisement
Log in to turn off these ads.