2013-04-22 46 views
1

我在註冊頁面中不斷收到此錯誤。當我調試我的系統時,所有的參數都給出..當進入for循環它也可以..但它進入內部捕獲並給我那個錯誤..插入錯誤:「@signupDate」附近的語法不正確

這裏是我的代碼.. 請幫助。 ..

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); 
+0

它看起來像'Java JDBC',是嗎?如果我是對的,請將標籤添加到您的問題中。 – 2013-04-22 03:52:43

+0

請將錯誤/異常本身與完全追溯(如果可用)。 – 2013-04-22 03:53:46

回答

2

它看起來像你缺少你的merchantQuery字符串上的圓括號。

+0

謝謝你......傻我...... :) @Carth – aianLee 2013-04-22 05:25:22

+0

樂意幫忙:) @aianLee – Carth 2013-04-22 13:30:47

相關問題