2013-04-22 49 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

相关问题