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);

ocmd.Parameters["@UserCode"] = TxtUserCode;

 

and also there is another error message saying that argument1: can not comvert from system.data.sqlclient.sqlparameter to string.

What am i Missing???

Eventually there is the try{open} and finally{close}

 

Many Thanks

 

PS: I am using C#

0
Jmurekezi
5/19/2008 1:03:17 PM
asp.net.object-datasource 16182 articles. 0 followers. Follow

3 Replies
879 Views

Similar Articles

[PageSpeed] 0

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));

ocmd.Parameters["@UserCode"] = TxtUserCode;

 

 

HTH 

 

------------------------------------------------------------------------------------------------
Don't forget to click "Mark as Answer" on the post that helped you. 

0
vinesh
5/19/2008 1:12:09 PM

ocmd.Parameters.Add(new SqlParameter("@UserCode"), SqlDbType.NVarChar);

Replace as follows .. note removed the extra braces 

ocmd.Parameters.Add(new SqlParameter("@UserCode", SqlDbType.NVarChar));

 


Jeev
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you get the answer to your question, please mark it as the answer.
0
Jeev
5/19/2008 1:13:52 PM

And change the line where you set the value of the parameter to fix the second error: 

ocmd.Parameters["@UserCode"].Value = TxtUserCode;
EDITED: Sorry, posted with wrong param name first. 
 
"Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
0
ramblor
5/19/2008 1:15:19 PM
Reply:

Similar Artilces:

Compiler Error Message: CS1501: No overload for method 'ToString' takes '1' arguments
Compiler Error Message: CS1501: No overload for method 'ToString' takes '1' argumentsSource Error: Line 248: //{ Line 249: Line 250: int RollNo = Convert.ToInt32(str.ToString(str.Append(GridView1.Rows[i].Cells[1].Text))); Line 251: Line 252: DeleteStudent(RollNo); Source File: h:\Office Works\Projects\Sample Applications\GridViewVitCode.aspx.cs    Line: 250 Please solve this problem  This is the complete code  protected void Button2_Click(object sender, EventArgs e) {for (int i = 0; i <...

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 At a surface leve...

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...

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><...

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); ocmd...

''''''''''''''''''''
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...

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...

'''''
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 ...

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...

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...

XmlSchema.Read error No overload method for 'read' takes '2' arguments
In pb12dotnet build 6107 I am developing an application to parse XML using the .Net classes. I have been able to read in and process XML data. Now I am trying to load a schema (xsd file) into the .net XmlSchema object. When I try to read in the schema into the object I am getting an error on XmlSchema.Read: "No overload for method 'read' takes '2' arguments." The XmlSchema.Read() method, however, always takes 2 arguments. Any suggestions on what is wrong. I was suspicious my ValidationEventHandler parm might be causing a problem, but I have not been able to...

Compilation Error: CS1501: No overload for method 'Photo' takes '3'arguments
Hi,I am in trying to have two different Categories of Photo Albums:e.g  1. Personal Album       2. Work AlbumAnd wish to have two seperate album pages (so one page with various 'Personal' albums and another page with just 'Work Albums'). I have created a field in the Albums table titled Category and made a few changes to some of the files. Problem is when I try to load up the website I get the following error:Compiler Error Message: CS1501: No overload for method 'Photo' takes '3' argumentsSource Error: Line 98: while (reader.Read())...

No overload for method 'ReportParameter' takes '2' arguments
I am trying to render a report that runs on our remote SQL Reporting Server to the ReportViewer control in my C# asp.net page.  The reports will need to have various parameters past to it.  However, every example I see on how to do this looks something like this (this is from MSDN):ReportParameter p = new ReportParameter("ShowDescriptions", "test");this.ReportViewer1.ServerReport.SetParameters(new ReportParameter[] { p }); However, this will not build for me, I get the error:No overload for method 'ReportParameter' takes '2' argumentsIn fact, when I mouse over ReportParameter,...

Web resources about - Error Message: No overload for method 'SqlParameter' takes '1' arguments - asp.net.object-datasource

Resources last updated: 1/21/2016 7:28:51 PM