开发者

error in web service and execute method

I wrote this web service with the following execute method. I would like your help about this error which I have in both the open and close:

System.Data.SqlClient.SqlConnection does not contain a definition for 'open' and no exception method 'open' excepting a first type of argument System.Data.SqlC开发者_高级运维lient.SqlConnection can be found

What I must change in my code?I think that in return this.ExecuteQuery(orderItem,conn); is my paroblem

[WebMethod(Description = "This will input computers into the database", EnableSession = false)]
public string orderItem(int CUS_ID, string COM_ID, int Quantity,double COMPrice)
{

    try
    {

        dbConn = new DbConnection();
        SqlConnection conn = dbConn.OpenConnection();
        SqlCommand orderItem = new SqlCommand("OrderComputer", conn);
        orderItem.CommandType = CommandType.StoredProcedure;


        SqlParameter add_CUS_ID = orderItem.Parameters.Add("@CUS_ID", SqlDbType.Int, 4);
        add_CUS_ID.Value = CUS_ID;

        SqlParameter addBK_ISBN = orderItem.Parameters.Add("@COM_ID", SqlDbType.Char, 80);
        addBK_ISBN.Value = COM_ID;

        SqlParameter add_Quantity = orderItem.Parameters.Add("@Quantity", SqlDbType.Int, 2);
        add_Quantity.Value = Quantity;

        SqlParameter add_COMPrice = orderItem.Parameters.Add("@COMPrice", SqlDbType.Money, 8);
        add_COMPrice.Value = COMPrice;


        return this.ExecuteQuery(orderItem,conn);
    }
    catch (Exception e)
    {
        return e.ToString();
    }
}

The executed:

   protected string ExecuteQuery(SqlCommand QueryObject, SqlConnection conn) 

     { 

       try

       {

     conn.open();

      int queryResult = QueryObject.ExecuteNonQuery(); 

      if (queryResult != 0) { 

         return "Your request is CORRECT"; 

      } 

      else 

  { 

   return "error: QueryResult= " + queryResult; 

      }
   }
   finally
   { 
      conn.close();
   }
}


type conn.Open() instead of conn.open(); and conn.Close() instead of conn.close(); and you should be ok. This is in the execute query method. C# is a case sensitive language.


try conn.Open(); instead of conn.open(); and conn.Close(); instead of conn.close(); .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜