CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Dec 2009
    Posts
    90

    Error when filling dataadapter

    hi

    I keep getting this message whenever I delete something from a database. What I am doing is implementing the delete fucntion for a post in a forum. I have two applciation a Webservice and a Website

    Here is my code for the method in the service
    Code:
    [WebMethod]
        public DataSet GetPosts(string queryStr)
        {
            DataSet ds = new DataSet();
            setupConnection();
            OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(queryStr, connection);
    
            myDataAdapter.Fill(ds, "Posts");
            connection.Close();
            return ds;
        }
    and here is the code in the website
    Code:
    protected void Repeater_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            DataSet ds;
            int postId = Convert.ToInt32(e.CommandArgument);
            switch (e.CommandName)
            {
                case "Del":
                    Response.Write("the id of the post clicked = " + postId);
                    string delPost = "DELETE * FROM Posts WHERE PostID =" + postId;
                    myws.DeletePost(delPost);
                    object temp = Session["trdID"];
                    int h = Convert.ToInt32(temp) + 1;
                    object temp2 = Session["secID"];
                    int i = Convert.ToInt32(temp2) + 1;
                    string queryStr = "SELECT Posts.*, Accounts.* FROM Posts INNER JOIN Accounts ON Posts.AccountID = Accounts.ID WHERE ThreadID = "+h+" AND SectionID = "+i+" ORDER BY DateCreated";
                    ds = myws.GetPosts(queryStr);
                    BindRepeater();
                    break;
    
                case "Edit":
                    break;
            }
        }
    However I get a SOAP exception on this line
    Code:
    ds = myws.GetPosts(queryStr);
    ...with...
    ____
    "System.Data.OleDb.OleDbException: No value given for one
    or more required parameters."
    ____


    This is due to the dataadapter not being able to be filled for some reason. I dont know if its because im deleting from an access database or not...


    Can anyone help?
    Last edited by dovobet; May 13th, 2010 at 08:06 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured