Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

PortalWebHosting
  Ads  
Active Modules -- Active Forums for DotNetNuke
 


  Sponsors  

Meet Our Sponsors

SteadyRain
DataSprings - Great Ideas. Always Flowing.
R2integrated - formerly bi4ce
Jango Studios - Skins, Modules and Hosting for DotNetNuke
eUKhost.com is commited to offer exceptional UK Windows Web Hosting solutions with quality 24x7 technical support.Our plans support ASP.Net, ASP, ASP.NET Ajax extensions, XML, MSSQL, MySQL, PHP,DNN, multiple domains and Shared SSL as standard.
SmarterTools
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  SQL Stored Procedure Error
Previous Previous
 
Next Next
New Post 10/27/2007 2:34 PM
User is offline Chris_Stewart
16 posts
10th Ranked


SQL Stored Procedure Error 

 

I'm trying to create the stored procedues that the starter kit creates by default.  I added my addtional columns and now get this error message;

System.Data.SqlClient.SqlException: Ambiguous column name 'FirstName'. Ambiguous column name 'LastName'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) ........

Here is the stored procedure.  When I delete FirstName and LastName it works just fine.

create procedure {databaseOwner}{objectQualifier}P4YS_GetContactMgr

@ModuleId int,

@ContactId int

as

select ModuleId,

ContactId,

Content,

CreatedByUser,

CreatedDate,

FirstName,

LastName,

PrimaryPhone,

SecondaryPhone,

Address,

Address2,

City,

State,

ZipCode,

Country

 

from {objectQualifier}P4YS_ContactMgr with (nolock)

left outer join {objectQualifier}Users on {objectQualifier}P4YS_ContactMgr.CreatedByUser = {objectQualifier}Users.UserId

where ModuleId = @ModuleId

and ContactId = @ContactId

On the P4YS_GetContactMgrs Stored Procedure I get an error "System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'as'. "

Here is that procedure:

create procedure {databaseOwner}{objectQualifier}P4YS_GetContactMgrs

@ModuleId int,

as

select ModuleId,

ContactId,

Content,

CreatedByUser,

CreatedDate,

FirstName,

LastName,

PrimaryPhone,

SecondaryPhone,

Address,

Address2,

City,

State,

ZipCode,

Country

 

from {objectQualifier}P4YS_ContactMgr with (nolock)

left outer join {objectQualifier}Users on {objectQualifier}P4YS_ContactMgr.CreatedByUser = {objectQualifier}Users.UserId

where ModuleId = @ModuleId

 

The other stored procedures Select, Add, Update, Delete all worked just fine.

 

 

 
New Post 10/28/2007 3:17 AM
User is offline Babar Javaid
142 posts
9th Ranked


Re: SQL Stored Procedure Error 

The Built-In Table Users contains the columns for the FirstName and LastName, Now it seems that your P4YS_ContactMgr table also contain the FirstName and LastName columns. You just need to specify the table table from which u want to get the FirstName and LastName. For example; if you pick the FirstName and LastName from the Users table then you Stored Procedure is given below

 

create procedure {databaseOwner}{objectQualifier}P4YS_GetContactMgr

@ModuleId int,

@ContactId int

as

select ModuleId,

ContactId,

Content,

CreatedByUser,

CreatedDate,

Users.FirstName,

Users.LastName,

PrimaryPhone,

SecondaryPhone,

Address,

Address2,

City,

State,

ZipCode,

Country

 

from {objectQualifier}P4YS_ContactMgr with (nolock)

left outer join {objectQualifier}Users on {objectQualifier}P4YS_ContactMgr.CreatedByUser = {objectQualifier}Users.UserId

where ModuleId = @ModuleId

and ContactId = @ContactId

-------------------------------------------------------

For your second error just remove the comma(,) at the end of @ModuleId parameter then this will work fine.


"Knowledge Sharing Matters!"
 
New Post 10/28/2007 6:01 PM
User is offline nminhkha
4 posts
www.nhaccuatui.com
10th Ranked


Re: SQL Stored Procedure Error 

" Ambiguous column name 'LastName' " this mean you have two or more table contain column LastName . You must use tablename.[column name] to access this column

 
New Post 10/28/2007 8:55 PM
User is offline Paul Scarlett
188 posts
www.tressleworks.ca
9th Ranked






Re: SQL Stored Procedure Error 

The second error listed is due to a comma ","  in   @ModuleId int,   just prior to the "AS" ... a possible cut and paste error ??

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  SQL Stored Procedure Error
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Alki Homes - Seattle, WA
Exemplary service for your Seattle Real Estate needs. It's what you deserve from your Realtor®!
www.alkihomes.com
PointClick DotNetNuke Solutions
PointClick Technologies provides high-end DNN Hosting for businesses.
PointClick.Net Hosted Solutions
Active Modules, Inc.
Creators of Active Forums, the best forum module for DotNetNuke
www.activemodules.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP