asiavoices
Programmer
Hello all,
I have problem that I cannot seem to narrow down.
Basically, my sp simply adds a new record to my db.
The Error I am getting is:
Error Diagnostic Information
ODBC Error Code = 37000 (Syntax error or access violation)
[Microsoft][ODBC SQL Server Driver][SQL Server]Error converting data type varchar to bit.
SQL = "usp_AddContact"
Data Source = "MYDBsource"
The error occurred while processing an element with a general identifier of (CFSTOREDPROC), occupying document position (9:2) to (9:72).
===============================
My observation:
The error seems to have stemmed from my "IsContactActive" field.
=====================================
Here is my form's SP code.
<cfstoredproc procedure="usp_AddContact" datasource="#application.ds#">
<cfprocparam type="In" cfsqltype="cf_sql_bit" dbvarname="@IsContactActive" value="#form.IsContactActive#">
<cfprocparam type="in" cfsqltype="cf_sql_varchar" dbvarname="@FirstName" value="#Trim(form.FirstName)#">
<cfprocparam type="in" cfsqltype="cf_sql_varchar" dbvarname="@LastName" value="#Trim(form.LastName)#">
<cfprocparam type="in" cfsqltype="cf_sql_varchar" dbvarname="@Title" value="#Trim(form.Title)#" null="#IIf(Trim(form.Title) EQ "", 1, 0)#">
........
</cfstoredproc>
===============================
On my form:
<form name="addcontactform" action="process.cfm">
.....
<input type="radio" name="IsContactActive" value="1" checked> Active
<input type="radio" name="IsContactActive" value="0"> Inactive
....
</form>
===========================
My "usp_AddContact" procedure
CREATE PROCEDURE usp_AddContact
@ContactID int,
@IsContactActive bit,
@FirstName nvarchar(50),
@LastName nvarchar(50),
@Title nvarchar(50) = null,
@Company nvarchar(50) = null,
@Address nvarchar(50) = null,
@City nvarchar(50) = null,
@ProvinceID int = null,
@OtherProvince nvarchar(99) = null,
@CountryID int = null,
@ZipCode nvarchar(50) = null,
@Phone nvarchar(50) = null,
@Cell nvarchar(50) = null,
@Fax nvarchar(50) = null,
@Emergency nvarchar(50) = null,
@Email nvarchar(50) = null,
@Notes text = null,
@IP nvarchar(16) = null
OUTPUT AS
BEGIN TRANSACTION
INSERT INTO tbl_Contacts
(IsContactActive, FirstName, LastName, Title, Company, Address, City, ProvinceID, OtherProvince, CountryID, ZipCode, Phone, Cell, Fax, Emergency, Email, Notes, IP)
VALUES (@isContactActive, @FirstName, @LastName, @Title, @Company, @Address, @City, @ProvinceID, @OtherProvince, @CountryID, @ZipCode, @Phone, @Cell, @Fax, @Emergency, @Email, @Notes, @IP)
SET @ContactID = @@identity
COMMIT TRANSACTION
GO
=========================================
MY tbl_Contact table
CREATE TABLE [dbo].[tbl_Contacts] (
[ContactID] [int] IDENTITY (1, 1) NOT NULL ,
[IsContactActive] [bit] NOT NULL ,
[IsContactDelete] [bit] NULL ,
[FirstName] [nvarchar] (80)
[LastName] [nvarchar] (80)
[Title] [nvarchar] (80)
[Company] [nvarchar] (100)
[Address] [nvarchar] (125)
[City] [int] NULL ,
[ProvinceID] [int] NULL ,
[OtherProvince] [nvarchar] (100)
[CountryID] [int] NULL ,
[Zipcode] [nvarchar] (25)
[Phone] [nvarchar] (20)
[Cell] [nvarchar] (20)
[Fax] [nvarchar] (20)
[Emergency] [nvarchar] (20)
[nvarchar] (100)
[Notes] [ntext]
[DateCreated] [datetime] NULL ,
[DateModified] [datetime] NULL ,
[IP] [nvarchar] (16)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
======================
Any ideas? It seems fine to me...
I'd like to use stored procedures to do all database transaction rather than cfquery to make it more efficient.
Thanks,
Christopher
I have problem that I cannot seem to narrow down.
Basically, my sp simply adds a new record to my db.
The Error I am getting is:
Error Diagnostic Information
ODBC Error Code = 37000 (Syntax error or access violation)
[Microsoft][ODBC SQL Server Driver][SQL Server]Error converting data type varchar to bit.
SQL = "usp_AddContact"
Data Source = "MYDBsource"
The error occurred while processing an element with a general identifier of (CFSTOREDPROC), occupying document position (9:2) to (9:72).
===============================
My observation:
The error seems to have stemmed from my "IsContactActive" field.
=====================================
Here is my form's SP code.
<cfstoredproc procedure="usp_AddContact" datasource="#application.ds#">
<cfprocparam type="In" cfsqltype="cf_sql_bit" dbvarname="@IsContactActive" value="#form.IsContactActive#">
<cfprocparam type="in" cfsqltype="cf_sql_varchar" dbvarname="@FirstName" value="#Trim(form.FirstName)#">
<cfprocparam type="in" cfsqltype="cf_sql_varchar" dbvarname="@LastName" value="#Trim(form.LastName)#">
<cfprocparam type="in" cfsqltype="cf_sql_varchar" dbvarname="@Title" value="#Trim(form.Title)#" null="#IIf(Trim(form.Title) EQ "", 1, 0)#">
........
</cfstoredproc>
===============================
On my form:
<form name="addcontactform" action="process.cfm">
.....
<input type="radio" name="IsContactActive" value="1" checked> Active
<input type="radio" name="IsContactActive" value="0"> Inactive
....
</form>
===========================
My "usp_AddContact" procedure
CREATE PROCEDURE usp_AddContact
@ContactID int,
@IsContactActive bit,
@FirstName nvarchar(50),
@LastName nvarchar(50),
@Title nvarchar(50) = null,
@Company nvarchar(50) = null,
@Address nvarchar(50) = null,
@City nvarchar(50) = null,
@ProvinceID int = null,
@OtherProvince nvarchar(99) = null,
@CountryID int = null,
@ZipCode nvarchar(50) = null,
@Phone nvarchar(50) = null,
@Cell nvarchar(50) = null,
@Fax nvarchar(50) = null,
@Emergency nvarchar(50) = null,
@Email nvarchar(50) = null,
@Notes text = null,
@IP nvarchar(16) = null
OUTPUT AS
BEGIN TRANSACTION
INSERT INTO tbl_Contacts
(IsContactActive, FirstName, LastName, Title, Company, Address, City, ProvinceID, OtherProvince, CountryID, ZipCode, Phone, Cell, Fax, Emergency, Email, Notes, IP)
VALUES (@isContactActive, @FirstName, @LastName, @Title, @Company, @Address, @City, @ProvinceID, @OtherProvince, @CountryID, @ZipCode, @Phone, @Cell, @Fax, @Emergency, @Email, @Notes, @IP)
SET @ContactID = @@identity
COMMIT TRANSACTION
GO
=========================================
MY tbl_Contact table
CREATE TABLE [dbo].[tbl_Contacts] (
[ContactID] [int] IDENTITY (1, 1) NOT NULL ,
[IsContactActive] [bit] NOT NULL ,
[IsContactDelete] [bit] NULL ,
[FirstName] [nvarchar] (80)
[LastName] [nvarchar] (80)
[Title] [nvarchar] (80)
[Company] [nvarchar] (100)
[Address] [nvarchar] (125)
[City] [int] NULL ,
[ProvinceID] [int] NULL ,
[OtherProvince] [nvarchar] (100)
[CountryID] [int] NULL ,
[Zipcode] [nvarchar] (25)
[Phone] [nvarchar] (20)
[Cell] [nvarchar] (20)
[Fax] [nvarchar] (20)
[Emergency] [nvarchar] (20)
[nvarchar] (100)
[Notes] [ntext]
[DateCreated] [datetime] NULL ,
[DateModified] [datetime] NULL ,
[IP] [nvarchar] (16)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
======================
Any ideas? It seems fine to me...
I'd like to use stored procedures to do all database transaction rather than cfquery to make it more efficient.
Thanks,
Christopher