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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Simple SQL QuestionSimple SQL Question
Previous
 
Next
New Post
11/3/2009 2:13 PM
 

Hello,

 

  I am trying to put a few lines in an SalDataProvider.  This works perfectly when I run it in a QUERY inside SQL Management Studio.

if col_length('dbo.VGN_SOAPBOX_SETTINGS', 'NAMETYPE') is null

ALTER TABLE VGN_SOAPBOX_SETTINGS ADD
[NAMETYPE] [int] NULL

UPDATE VGN_SOAPBOX_SETTINGS
SET [NAMETYPE] = 0 WHERE [NAMETYPE] IS NULL

 

  It executes just fine.  But when I run it in DNN as a script in the SQL section, I always get...

 

System.Data.SqlClient.SqlException: Invalid column name 'NAMETYPE'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at DotNetNuke.Data.SqlDataProvider.ExecuteADOScript(String SQL) at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions) if col_length('dbo.VGN_SOAPBOX_SETTINGS', 'NAMETYPE') is null ALTER TABLE VGN_SOAPBOX_SETTINGS ADD [NAMETYPE] [int] NULL UPDATE VGN_SOAPBOX_SETTINGS SET [NAMETYPE] = 0 WHERE [NAMETYPE] IS NULL

 

 

 

  I have tried numerous ways to test if the column is there, and I always get the same sort of error.  I just want to test for the column and then execute if it doesn't exist.  Why doesn't this work when I run it in DNN, but does work in SQL Management Studio?  Or can someone tell me how to test for a column in DNN that WILL work?  Thanks.

 
New Post
11/4/2009 12:13 AM
 
  • make sure to save your script in Unicode (UTF-8) before pasting test
  • you may use " instead of ' as text delimiter.

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
11/4/2009 12:29 AM
 

Thanks for replying Sebastian, but that didn't work.

It still tests for NAMETYPE and says it's not there.  Which is why I'm asking it to see if it's NULL, but instead it errors out.  Same piece of code works fine in SQL Management Console as a Query.  But does not work when run as a script.  I cannot figure out how to get this to work either here, or as part of a data provider as it just always throws an error.  I'm dumbfounded.

 
New Post
11/4/2009 5:03 AM
 

DNN is using Microsoft Data Access Block (a rather old version) for accessing SQL server, there might be limitations of supported SQL features. Please check out MSDN for details


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
11/5/2009 5:20 PM
 

Ok, but beyond reading all this, is there a known simple way I can test for a column?  Everything I try throws errors.  How does everyone else do it?  I'm looking for a simple example, or should I create a new forum post?

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Simple SQL QuestionSimple SQL Question


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