Click here to Skip to main content
15,039,541 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am trying to run a autofill textbox using db2 database
it is running fine with sql server but how can i do it with ibmdb2
the code is :
aspx:
XML
<asp:TextBox ID="txtSourceSystem" runat="server"  style="background-color: #3e89d7; color: #FFFFFF;"></asp:TextBox>

                            <cc1:AutoCompleteExtender ServiceMethod="SearchCountry" MinimumPrefixLength="1" CompletionInterval="100"
                                EnableCaching="false" CompletionSetCount="1" TargetControlID="txtSourceSystem"
                                ID="AutoCompleteExtender1" runat="server" FirstRowSelected = "false">
                           </cc1:AutoCompleteExtender>


cs page is:
C#
public static List<string> SearchCountry(string prefixText, int count)
        {
            // DB2Connection conn = new DB2Connection("Server=DEV4131;Database=FTEDB;UID=db2admin;PWD=db2admin;");
            using (DB2Connection conn = new DB2Connection())
            {

                conn.ConnectionString = ConfigurationManager.ConnectionStrings["DB2ConnectionString"].ConnectionString;

                using (DB2Command cmd = new DB2Command())
                {

                    cmd.CommandText = "select JOB_NAME from FTELOG.TRANSFER where " + "JOB_NAME like @SearchText + '%'";
                    cmd.Parameters.Add("@SearchText", prefixText);

                    cmd.Connection = conn;
                    conn.Open();
                    List<string> country = new List<string>();
                    using (DB2DataReader db2dr = cmd.ExecuteReader())
                    {
                        while (db2dr.Read())
                        {
                            country.Add(db2dr["JOB_NAME"].ToString());
                        }
                    }
                    conn.Close();
                    return country;
                }
            }
        }


and it is showing error is db2Exception unhandled by usercode
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900