what does 'No overload for method 'Insert' takes '1' arguments' mean?

code that caused this error: line AddInBookSqlDataSource2.Insert(item);

protected void inbookButton_Click(object sender, EventArgs e){

try{

AddInBookSqlDataSource1.Insert();

}

catch (Exception ex){

uploadSPoneLabel.Text = "Saved Failed: SP One" + ex.Message;

}

foreach (ListItem item in authorsListBox5.Items){

try{

AddInBookSqlDataSource2.Insert(item);

saveStatusLabel.Text = "Save Successful: SP Two";

}

catch (Exception ex1){saveStatusLabel.Text = "Save Failed: SP Two" + ex1.Message;

}

}

}

any help appreciated

Thanks in advance

0
gcp2985
12/10/2007 11:59:07 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

1 Replies
765 Views

Similar Articles

[PageSpeed] 39

At a surface level, your problem is that the Insert() method of a SqlDataSource does not take any parameters - so the line: AddInBookSqlDataSource2.Insert(item); can not work.

Using your approach, you could change that line of code in your foreach loop to something like:

AddInBookSqlDataSource2.InsertParameters.Clear();
AddInBookSqlDataSource2.InsertParameters.Add("parameterName", item.Text);
AddInBookSqlDataSource2.Insert(item);

** This assumes you have set your AddInBookSqlDataSource2.InsertCommand - and that it takes in a parameter... which i have named "parameterName", as i have no idea what you are grabbing from your ListItems and putting in the database.

You may also want to read up on using a DataSet, DataTable and DataTableAdapter - using these may provide a more robust solution to your problem.

Tones.
 


Tony Milne is a co-founder of Inlight Media, a leading Australian web development company.
0
TonyMilne
12/11/2007 1:22:57 AM
Reply:

Similar Artilces:

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

'''''
Name: mario Email: ramar17atfastwebnetdotit Product: Gran Paradiso Alpha 2 Summary: ''''' Comments: K: Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2) Gecko/20070206 GranParadiso/3.0a2 ...

No overload for method 'FormatImagePath' takes '1' arguments
Hi, I am getting the error message above on the code below.  I did not write the code.  I am new to ASP.NET and I had to download Visual Studio 2005 to compile my C# files.  The website was written in a previous version and the error message appeared when I tried compiling after the conversion to ASP.NET 2.0. by Visual Studio.  I don't understand the error message and I am not entirely clear on what the code is doing.  Would anyone be able to help?    <table> <tr><td></td></tr> <tr><...

No overload for method 'Forum' takes '1' arguments
I am getting this error - No overload for method 'Forum' takes '1' argumentsCan anyone help?I am using a web service created by myself Topic Page<asp:HyperLinkField DataNavigateUrlFormatString="~/topic.aspx?TopicID={0}" NavigateUrl="~/topic.aspx" Text="Comments" DataNavigateUrlFields="TopicID" />Comments Page localhost.Topic topic = new localhost.Topic(); string topicId = Request.QueryString["TopicID"].ToString(); datasource = topic.Forum("SELECT * FROM Comment WHERE TopicID =" +topicId); GridView1....

No overload for method 'FieldValue' takes '1' arguments
Very confused, the recordset returns a record, all is working, but it's just giving me an error?????? anybody knows how to solve this, Compiler Error Message: CS1501: No overload for method 'FieldValue' takes '1' arguments Source Error: Line 19: { Line 20: Line 21: Response.Redirect(ds_redirect.FieldValue("url")); Line 22: } Line 23: ---------------------------- When removing the fieldvalue I receive another error Compiler Error Message: CS0118: 'ASP.frame_redirect_url_aspx.ds_redirect' denotes a 'field' where a 'method' was expected...

'do' won't 'do' if '/'
Greetings to All from Au, Have a NetWare Perl 5.8.4 and wanted to tweak File\Spec\NW.pm to try and standardise on '/' separators. If I run a test script (t/uni/lower.t) with an unmodified NW.pm, it calls t/uni/case.pl, that, in case.pl, (when the path separators are '\'), the $file is '..\lib\unicore\To\Lower.pl' and the following code portion works, with $simple getting a returned table: sub casetest { my ($base, $spec, $func) = @_; my $file = File::Spec->catfile(File::Spec->catdir(File::Spec->updir, "lib", &qu...

'''
Name: L Lachowsky Email: e2brutus_10atyahoodotcom Product: Firefox Summary: ''' Comments: why duddn this surprise me... I change default server from IE to Mozilla, and then i get error messages. well, shud I decide to not get on my computer with Mozilla..or shud I risk security breeches with IE....hmmm at least i can get on the internet with IE Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this fee...

CS1501: No overload for method 'Insert' takes '5' arguments
 Hi,Can some one please help me im getting this error and i cant figuer out way its happening this is the full error i get... Compiler Error Message: CS1501: No overload for method 'Insert' takes '5' arguments Source Error: Line 27: DataSetTableAdapters.MemberInfoTableAdapter da = new DataSetTableAdapters.MemberInfoTableAdapter();Line 28: MembershipUser user = Membership.GetUser(CreateUserWizard1.UserName);Line 29: ...

CS1501: No overload for method 'ToShortDateString' takes '1' arguments
Hello,  I'm quite new in ASP.NET. I'm developing a website for my company where people can request a reservation. Therefor I made a form where there is a Calendar where they can pick a date for their reservation-request. I'd like to make all the dates 'till "today+1" unselectable. I didn't found a way to do this so I use a CompareValidator to check whether the day they selected is "greater than today". Unfortunately I get this errormessage "CS1501: No overload for method 'ToShortDateString' takes '1' arguments" while it is a solution I found on the web. Can someone please help me. Than...

Cast from type ''''DBNull'''' to type ''''String'''' is not valid.
How do I avoid getting this error: Cast from type ''''DBNull'''' to type ''''String'''' is not valid. I am trying to get values from the database into a form for updating using a Datareader, SQL is set to allow nulls for certain fields as they are not required but the only way I can get the form to display is by adding a space in SQL. Is there another way around this? Check if it is equal to DBNull.Value first and if it is, don't do the cast.Stanley Tan theSpoke Blog Where in the code does it need to go? I am using the following and it's the profile that isn't always requi...

table_info('','','','%') cannot return any types
I was recently confirming table_info special cases and discovered the case for getting table_types cannot work. table_info('','','','%') should return a list of table types but it returns a list of empty strings instead: my @types = $h->tables('', '', '', '%'); print "all types:\n", join("xxx\n", @types), "\n"; # should output something like: # "dbo" # "INFORMATION_SCHEMA" # "sys" # and actually outputs: xxx xxx It seems to be down to the following ...

Argument '1': cannot convert from 'object' to 'int'
 I am calling a function from a label control in my gridview.. <asp:Label ID="Label1" runat="server" Text='<%# ShowCategoriesForPID(Eval("pol_id")) %>'/> But i get following error when i compile -error CS1503: Argument '1': cannot convert from 'object' to 'int'  pol_id is an integer value and my function receives it as an integer argument.  I dont know whats wrong? The "Eval" function returns an object. To need to cast it's result: <asp:Label ID="Label1" runat="s...

Error Message: No overload for method 'SqlParameter' takes '1' arguments
Dear All,   I have a problem while trying to update the content of my page to the database by the means of a stored procedure string OcompConnection = ConfigurationManager.ConnectionStrings["GenUserCode"].ConnectionString;  System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(OcompConnection); System.Data.SqlClient.SqlCommand ocmd = new System.Data.SqlClient.SqlCommand("Dealer_Insert", conn);ocmd.CommandType = CommandType.StoredProcedure; ocmd.Parameters.Add(new SqlParameter("@UserCode"), SqlDbType.NVarChar); oc...

Web Service
[WebMethod]public DataSet GetDataSetForum2(){DataSet datasource = new DataSet();string database = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/topic.mdb;Persist Security Info=True";string queryStr = "Select * from Comment";OleDbConnection myConn = new OleDbConnection(database);OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(queryStr, myConn);myConn.Open();myDataAdapter.Fill(datasource, "Comment");myConn.Close();return datasource;} localhost.Topic topic = new localhost.Topic(); string topicId = Request.QueryString["TopicID"].To...

Web resources about - what does 'No overload for method 'Insert' takes '1' arguments' mean? - asp.net.sql-datasource

Resources last updated: 12/16/2015 9:23:04 AM