1

我在注册页面中不断收到此错误。当我调试我的系统时,所有参数都给出了..当进入for循环时它也可以工作..但它进入catch内部并给我那个错误..

这是我的代码..请帮助...

private void ExecuteInsert(int MerchanttID, int ResellermID, string CompanyName, int AddID,
string streetAdr, string city, string state, int countryID, string zipCode, string TelNum,
string FaxNum, string Url, int IndustryID, Boolean isActive, Boolean isDeleted, 
DateTime DateCreated)
        {
            SqlConnection connectionString = new SqlConnection(GetConnectString());

            string merchantQuery = "Insert INTO Merchant_Master (MerchantTypeID,
     ResellerMasterID, CompanyName, AddressID, Url, IndustryID, IsActive, IsDeleted,
     DateCreated) VALUES (@merchantTID, @resellerMID , @CompanyName, @AddID, @website,
     @IDindustry, @Isactive, @IsDeleted, @signupDate"; 

            string addressQuery = "Insert into Address (StreetAdd, City, State, CountryID,
     ZipCode, TelNum, FaxNum) VALUES (@stAd, @CityAdr, @StateAdr, @IDcountry,
     @zCode ,@Tnumb ,@Fnumb)";                                  

            try
            {
                connectionString.Open();

                // Insert Merchant_Master
                SqlCommand merchantCmd = new SqlCommand(merchantQuery, connectionString);
                SqlParameter[] merchant = new SqlParameter[9];

                merchant[0] = new SqlParameter("@merchantTID", SqlDbType.VarChar, 100);
                merchant[1] = new SqlParameter("@resellerMID", SqlDbType.VarChar, 100);
                merchant[2] = new SqlParameter("@CompanyName", SqlDbType.VarChar, 100);
                merchant[3] = new SqlParameter("@AddID", SqlDbType.Int, 100);
                merchant[4] = new SqlParameter("@website", SqlDbType.VarChar, 100);
                merchant[5] = new SqlParameter("@IDindustry", SqlDbType.Int, 100);
                merchant[6] = new SqlParameter("@Isactive", SqlDbType.Bit, 100);
                merchant[7] = new SqlParameter("@IsDeleted", SqlDbType.Bit, 100);
                merchant[8] = new SqlParameter("@signupDate", SqlDbType.DateTime, 0);

                merchant[0].Value = MerchanttID;
                merchant[1].Value = ResellermID;
                merchant[2].Value = CompanyName;
                merchant[3].Value = AddID;
                merchant[4].Value = Url;
                merchant[5].Value = IndustryID;
                merchant[6].Value = isActive;
                merchant[7].Value = isDeleted;
                merchant[8].Value = DateTime.Now;

                for (int i = 0; i < merchant.Length; i++)
                {
                    merchantCmd.Parameters.Add(merchant[i]);
                }
                merchantCmd.CommandType = CommandType.Text;
                merchantCmd.ExecuteNonQuery();

                // Insert Address
                SqlCommand addressCmd = new SqlCommand(addressQuery, connectionString);
                SqlParameter[] address = new SqlParameter[7];

                address[0] = new SqlParameter("@stAd", SqlDbType.VarChar, 100);
                address[1] = new SqlParameter("@CityAdr", SqlDbType.VarChar, 100);
                address[2] = new SqlParameter("@StateAdr", SqlDbType.VarChar, 100);
                address[3] = new SqlParameter("@IDcountry", SqlDbType.Int, 100);
                address[4] = new SqlParameter("@zCode", SqlDbType.VarChar, 100);
                address[5] = new SqlParameter("@Tnumb", SqlDbType.VarChar, 100);
                address[6] = new SqlParameter("@Fnumb", SqlDbType.VarChar, 100);

                address[0].Value = streetAdr;
                address[1].Value = city;
                address[2].Value = state;
                address[3].Value = countryID;
                address[4].Value = zipCode;
                address[5].Value = TelNum;
                address[6].Value = FaxNum;

                for (int i = 0; i < address.Length; i++)
                {
                    addressCmd.Parameters.Add(address[i]);
                }
                addressCmd.CommandType = CommandType.Text;
                addressCmd.ExecuteNonQuery();
            }

            catch (Exception ex)
            {
                string errorMsg = "Insert Error:";
                errorMsg += ex.Message;
                throw new Exception(errorMsg);
            }
            finally 
            {
                connectionString.Close();
            }
        }

        protected void Submitbtn_Click(object sender, EventArgs e)
        {
            int AdrID = 0;
            Boolean isactive = true;
            Boolean isdeleted = false;

            ExecuteInsert ( int.Parse(drpR.SelectedValue),
                            int.Parse(drpT.SelectedValue),
                            CompanyName.Text,
                            AdrID,
                            stADR.Text,
                            City.Text,
                            State.Text,
                            int.Parse(drpC.SelectedValue),
                            Zcode.Text,
                            TNumber.Text,
                            FNumber.Text,
                            Url.Text,
                            int.Parse(drpI.SelectedValue),
                            isactive,
                            isdeleted,
                            DateTime.Now);
4

1 回答 1

2

您的 MercerQuery 字符串似乎缺少右括号。

于 2013-04-22T04:00:57.020 回答