dbTalk Databases Forums  

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Microsoft OLE DB Provider for ODBC Drivers error '80040e14' in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bhavna
 
Posts: n/a

Default Microsoft OLE DB Provider for ODBC Drivers error '80040e14' - 08-14-2007 , 02:47 PM






I have recently updated the stored procedure and now I am getting
"Microsoft OLE DB Provider for ODBC Drivers error '80040e14' .
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name
'bbakshi'. " error message. Here is the stored procedure

CREATE PROCEDURE stp_ExportMeetings @selmeetings varchar(8000), @user
varchar(50)
AS

DECLARE @sql varchar(8000)
DECLARE @empty varchar(1)
SET @empty = ''


SELECT @sql = 'UPDATE tblWrkshops SET Exported = 1, ExportDate =
GETDATE(), ExportedBy = "' + @user + '"
WHERE (tblWrkshops.Exported is null) OR (tblWrkshops.Exported <> 1)
and tblWrkshops.SetupNumb in (' + @selmeetings + ')'
EXEC (@sql)

SELECT @sql = 'SELECT tblWrkshops.MeetingCode, SessionNumber=
ISNULL(tblWrkshopSubjects.SessionNumb, ''01''),
tblSessionCons.ConsultantCode,
tblWrkshopSubjects.SubjectTitle, GenSubject =
tbl_Subject_Code.parent_session_code,
tbl_lkp_ParentSessionCodes.ParentSessionTitle
FROM tblWrkshops LEFT JOIN tblWrkshopSubjects ON
tblWrkshops.SetupNumb = tblWrkshopSubjects.SetupNumb
LEFT JOIN tblSessionCons ON tblWrkshopSubjects.WkshopSubjctID =
tblSessionCons.WkshopSubjctID AND
tblSessionCons.ConsultantType="Primary"
LEFT JOIN tbl_Subject_Code ON tblWrkshopSubjects.GenSubject =
tbl_Subject_Code.Subject_Code_pk
LEFT JOIN tbl_lkp_ParentSessionCodes ON
tbl_Subject_Code.parent_session_code =
tbl_lkp_ParentSessionCodes.ParentSessionCode
WHERE tblWrkshops.SetupNumb in (' + @selmeetings + ') and
tbl_lkp_ParentSessionCodes.DeleteMe=0'
EXEC (@sql)
GO

Quote:
From the asp page I am passing the parameters
strSQL = "stp_ExportMeetings '" & selected_meetings & "', " &
strExportUser & ""
objRS.Open strSQL, objCN

Any help is appreciated!

Thanks,
Bhavna



Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Microsoft OLE DB Provider for ODBC Drivers error '80040e14' - 08-14-2007 , 04:19 PM






Bhavna (bhavnabakshi (AT) hotmail (DOT) com) writes:
Quote:
I have recently updated the stored procedure and now I am getting
"Microsoft OLE DB Provider for ODBC Drivers error '80040e14' .
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name
'bbakshi'. " error message. Here is the stored procedure

CREATE PROCEDURE stp_ExportMeetings @selmeetings varchar(8000), @user
varchar(50)
AS

DECLARE @sql varchar(8000)
DECLARE @empty varchar(1)
SET @empty = ''


SELECT @sql = 'UPDATE tblWrkshops SET Exported = 1, ExportDate =
GETDATE(), ExportedBy = "' + @user + '"
WHERE (tblWrkshops.Exported is null) OR (tblWrkshops.Exported <> 1)
and tblWrkshops.SetupNumb in (' + @selmeetings + ')'
EXEC (@sql)
You get the error because you try to use " as a string delimiter. By
default, " delimits identifiers not string literals.

But you should never interpolate values into the query string. And in
this case there is no reason to use dynamic SQL at all:

UPDATE tblWrkshops
SET Exported = 1,
ExportDate = GETDATE(),
ExportedBy = @user
FROM tblWrkshops W
JOIN iter_intlist_to_table (@selmeetings) i ON W.SetupNumb = i.number
WHERE (tblWrkshops.Exported is null) OR (tblWrkshops.Exported <> 1)


You find iter_intlist_to_table on
http://www.sommarskog.se/arrays-in-s...st-of-integers

Note: that article is for SQL 2000. If you are on SQL 2005, there is
a separate article for SQL 2000.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
Reply




Thread Tools
Display Modes

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

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.