Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesError when getting userID and ModuleIDError when getting userID and ModuleID
Previous
 
Next
New Post
2/5/2012 12:59 AM
 

Hi,

I am getting an error when trying to use ModuleID and UserId in a query, If I put them into a label to show up on the page, they show up correctly, but as soon as I do:

cmd.Parameters.Add(new SqlParameter("@prmModuleID", SqlDbType.Int)).Value = mod;
cmd.Parameters.Add(new SqlParameter("@prmUserID", SqlDbType.Int)).Value = userID;

(mod and userID are defined earlier in the code)

I get the following error: Incorrect syntax near 'ModuleID'.  if I remove the add param to moduleID it changes to Incorrect syntax near 'UserID'

the line of code it is saying the error is occuring on is: SqlDataReader rd = cmd.ExecuteReader();

has anyone experienced this issue before?

Thanks,

Chris


 
New Post
2/5/2012 4:56 PM
 

Ok doing some more fiddling with this I think it something to do with the SQL Command. My sql string looks like this:

String sql = "SELECT [ItemID], [ItemName], [CategoryName], [ModuleID], [UserID]";
sql = sql + "FROM Items INNER JOINCategories ON Items.CategoryID = Categories.CategoryID";
sql = sql + "WHERE ModuleID = 423 AND UserID = 1";

If I have there Where, And statement I get the error from my first post, If I take it out it works fine. I cant see anything wrong with the SQL though.

Chris


 
New Post
2/6/2012 9:49 AM
 

What are the database column data types of ModuleID and UserID? Are they int or one of the character string types?

Although I don't usually build queries by string concatenation, it appears that you need spaces before FROM and before WHERE in the second two statements:

String sql = "SELECT [ItemID], [ItemName], [CategoryName], [ModuleID], [UserID]";
sql = sql + " FROM Items INNER JOIN Categories ON Items.CategoryID = Categories.CategoryID";
sql = sql + " WHERE ModuleID = 423 AND UserID = 1";

Finally, I assume that you are hardcoding 423 and 1 in the WHERE clause for testing purposes and will replace those by the parameter names.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
2/6/2012 1:56 PM
 
you were correct, it was the spaces that were the problem. And yes those were hardcoded for testing, I have the parameters in there, but was trying to work down the error.

Thanks for your help, dont know how I missed that one.

Chris
 
New Post
2/7/2012 11:54 AM
 
Dear Sir's

I want to develop my one module, i want to know show one of my data base table to one's how are login as Register User.
Can Any one help me know, which code check the user login and user ID?
What is the file name , and how should i use it in my code?

Many Thanks
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesError when getting userID and ModuleIDError when getting userID and ModuleID


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, 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 DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out