Click here to Skip to main content
15,890,995 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
public void AddnewRecord(string title_id, string title, string type, string pub_id, string price, string advance, string royalty, string ytd_sales, string notes, string pubdate)
    {
        sn = new SqlConnection("Data Source=VITSERVER;Initial Catalog=pubs;User ID=sa;Password=vit");
        string sqlstat = "INSERT into titles" + "(title_id,title,type,pub_id,price,advance,royalty,ytd_sales,notes,pubdate)" +
                        " VALUES(@title_id,@title,@type,@pub_id,@advance,@royalty,@ytd_sales,@notes,@pubdate)";
        try
        {
            sn.Open();
            cmd = new SqlCommand(sqlstat, sn);
            cmd.Parameters.AddWithValue("@title_id", title_id);
            cmd.Parameters.AddWithValue("@title", title);
            cmd.Parameters.AddWithValue("@type", type);
            cmd.Parameters.AddWithValue("@pub_id", pub_id);
            cmd.Parameters.AddWithValue("@price", price);
            cmd.Parameters.AddWithValue("@advance", advance);
            cmd.Parameters.AddWithValue("@royalty", royalty);
            cmd.Parameters.AddWithValue("@ytd_sales", ytd_sales);
            cmd.Parameters.AddWithValue("@notes", notes);
            cmd.Parameters.AddWithValue("@pub_id", pub_id);
            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();
        }
        catch(System.Data.SqlClient.SqlException ex)
        {
            string msg="INSERT error:";
            msg += ex.Message;
            throw new Exception(msg);
        }
        finally
            {
            sn.Close();
            }
    }



while debugging i am getting error as

VB
Error   1   No overload for method 'AddnewRecord' takes '9' arguments   
Posted

1 solution

please Look your code carefully before posting

There are 10 arguments in you AddnewRecord function and may from where you are calling passing only 9

:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900