database custom tag ?

  • jowy

    jowy - 2007-04-17

    Hi there!
    I want to ask about error that occurs when i use database custom tag
    the error is :

    WARNING! A problem was encountered when trying to process
    the input: CUSTOM TAG DATABASETAG halo
    with WARNING! A problem was encounter when trying to process
    the input:
    with the template:

    the script is:

    using System;
    using System.Collections.Generic;
    using System.Text;
    using AIMLbot;
    using System.Xml;
    using AIMLbot.Utils;
    using System.Data.OleDb;
    using System.Data;

    namespace ExampleCustomAIMLTags
        public class databasetag : AIMLTagHandler
            public databasetag()
                this.inputString = "databsetag";

            protected override string ProcessChange()
                if (this.templateNode.Name.ToLower() == "databasetag")
                    String bahancari = this.templateNode.InnerText;
                    //connect to database
                    OleDbConnection con =
                    new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" +
                    "Data Source=C:\\Documents and Settings\\Jowy Blight\\Desktop\\FinalWebsite\\App_Data\\dbresep.mdb;" +
                    "User ID=;Password=;");
                    //query select
                    OleDbDataAdapter adpt = new OleDbDataAdapter("SELECT namamasakan FROM masakan, mixbahan WHERE mixbahan.namabahan="+bahancari+" AND masakan.idresep=mixbahan.idresep", con);
                    DataSet msk = new DataSet();

                    adpt.Fill(msk, "masakan");

                    String hasilcari = String.Empty;
                    //concat every query result into 1 string named hasilcari
                    foreach (DataRow r in msk.Tables["masakan"].Rows)
                        hasilcari += r["namamasakan"].ToString();
                    //return hasilcari
                    return "tag berhasil"+hasilcari;
                return string.Empty;           

    any idea??

    • Nicholas Tollervey

      Hi Jowy,

      I'll look into this when I get time later this week.

      However, you could help yourself by attaching the AIMLBot source project to your application's process and catching the error. I admit, after checking the code in the library, the exception's message should be written to the log/output. I'll update this in the next release, but in the meantime you might want to change line 684 in the Bot.cs class to:

      this.writeToLog("WARNING! A problem was encountered when trying to process the input: " + request.rawInput + " with the template: \&quot;" + query.Template + "\&quot;"+Environment.NewLine+e.Message);

      Recompile the bot and re-link the reference to the new .dll as required and the error message should be a lot more useful.

      To attach to the process of your running program do the following:

      1. Put a break-point at the appropriate place in the code to help you start debugging your problem.
      2. In VS2005 select the Debug->Attach to process... menu item.
      3. From the "Available Processes" area select your application's process name then click the Attach process at the bottom.

      When the application hits the breakpoint you'll be dropped into the Debugger (also make sure that the .dll was compiled as "Debug" not "Release").

      Apologies if this seems obvious to you but I have to cover all the bases... :-)

      Perhaps you ought you to exercise your own code behind a unit test to make sure the error is definitely in the AIMLBot code? Although I'm happy to help solve problems within AIMLBot itself, make improvements in light of user feedback and appreciate the effort people take to report bugs - I can't (and shouldn't for legal / intellectual property reasons) help with problems in third party code should they arise whilst using AIMLBot. I'm sure you appreciate that life is a lot simpler if developers don't accidently leak code into applications that might not be appropriately (open-source) licensed.

      Best of luck, let me know how you get on and I'll take a better look when I get more time later this week.



Log in to post a comment.