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 ExtensionsModulesModulesFusionWidgetsFusionWidgets
Previous
 
Next
New Post
11/7/2014 11:11 AM
 

Thanks for the reply. I did check that and it appears to be loaded by the browser. After further review, I believe there is an issue with obtaining the XML string from the database...

The function I have written in the .cs is returning the data from the database, but when I attempt to populate my string, nothing is returned... Seems rather basic, not sure why it wouldn't be working. Seems to be an issue with the last piece in the .cs: strXML = dt.Rows[0][0].ToString();

I've returned Rows.Count.ToString() and it appears that the DataTable is populating, but for some reason attempting to populate strXML with that data is not working. Is there some syntax in DNN that I'm not familiar with that differs from my function (that works) in Visual Studio? Many thanks in advance.


Code:

      public string Sparks(string Section, string Report, string Identifier)

        {

            DataTable dt = null;

            SqlConnection cn = null;

            SqlCommand cmd = null;

            SqlDataReader reader = null;

            string SQL = "";

            string strXML = "";

            string CnString = "";

            try

            {

                // build query

                SQL = "EXEC InsertGenericProcNameHere 0";

                SQL += ",'" + Section;

                SQL += "','" + Report;

                if (Identifier == "")

                    SQL += "',NULL";

                else

                    SQL += "','" + Identifier + "'";

                SQL += ",NULL";              

              

               // create connection string

                CnString = System.Configuration.ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString;

              

               // create & open connection

               cn = new SqlConnection(CnString);

                cn.Open();

              

               // create command

                cmd = new SqlCommand(SQL, cn);

                cmd.CommandTimeout = 60;

              

               // obtain results from query

                reader = cmd.ExecuteReader(CommandBehavior.SingleResult);

              

               // populate datatable with results

                dt = new DataTable();

                dt.Load(reader);

                dt.AcceptChanges();

              

               // ensure the datatable has returned a result,

               // if so, set string to result

               if (dt != null && dt.Rows.Count > 0)

               strXML = dt.Rows[0][0].ToString();

            }

            catch (Exception ex)

            {

                // log error here

            }

            return strXML;

        }


 
New Post
11/10/2014 12:03 PM
 
no, there is no special DNN syntax for coding -there is for the database object name as DNN supports objectqualifier/databaseowner, so ensure you are calling a valid stored procedure (as I see you have a hard-coded name)

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
11/10/2014 12:35 PM
 

Thanks, Cathal. It does not appear that there is an issue with obtaining the data from the database. It appears that the issue is setting the string to the first row, first column of the returned datatable... For whatever reason, the string simply does not get set and the function fails to return the string.

 
New Post
11/10/2014 2:25 PM
 
Then I don't think this is a DNN problem. What you are looking at is plain ordinary code. DNN neither makes it work, nor stops it working.

Best wishes,
- Richard
Agile Development Consultant, Practitioner, and Trainer
www.dynamisys.co.uk
 
New Post
11/10/2014 2:25 PM
 
Attach the debugger and step through it. That may give you clues.

Best wishes,
- Richard
Agile Development Consultant, Practitioner, and Trainer
www.dynamisys.co.uk
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesFusionWidgetsFusionWidgets


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