TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
aditya immadi
NA
205
71.6k
Procedure or function spuserdata has too many arguments spec
Sep 27 2013 4:29 PM
Hai all, just look at my code::
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
/// <summary>
/// Summary description for DataClass
/// </summary>
///
public class DataClass
{
public DataClass()
{
}
/// <summary>
/// return rows depend on position
/// if you need 10th to 20th you need to pass start=10 and end=20
/// </summary>
/// <param name="start">database start position of one row</param>
/// <param name="next">database end position of one row</param>
/// <returns></returns>
public string GetAjaxContent(int start, int end)
{
string result = string.Empty;
//adding sp params with values in Dictionary entry.
Dictionary<string, object> keyValPair = new Dictionary<string, object>();
keyValPair.Add("@start", start);
keyValPair.Add("@next", end);
DBHelper DBHelper = new DBHelper();
//passing the Stored Procedure name and keyvalue pair
DataTable dataTable = DBHelper.GetTable("spuserdata", keyValPair);
if (dataTable.Rows.Count > 0)
{
for (int i = 0; i < dataTable.Rows.Count; i++)
{
result += string.Format(@"<tr>
<td>
<table>
<tr>
<td style='width:50px;'>{0}</td><td style='width:400px;'>{1}</td><td style='width:150px;'>{2}</td>
</tr>
</table>
</td>
</tr>", dataTable.Rows[i][0].ToString(), dataTable.Rows[i][1].ToString(), dataTable.Rows[i][2].ToString());
}
}
//this string is going to append on Datalist on client.
return result;
}
/// <summary>
/// function to bind data on page load
/// </summary>
/// <returns></returns>
public DataTable FirstTenRecords()
{
Dictionary<string, object> keyValPair = new Dictionary<string, object>();
keyValPair.Add("@start", 0);
keyValPair.Add("@next", 10);
DBHelper DBHelper = new DBHelper();
DataTable dataTable = DBHelper.GetTable("spuserdata", keyValPair);
return dataTable;
}
}
/// <summary>
/// return sqlconnection string formweb.config file
/// </summary>
public class Provider
{
public static SqlConnection GetConnection()
{
// return new SqlConnection(ConfigurationManager.AppSettings["conn"]);
return new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
}
}
/// <summary>
/// Data layer
/// </summary>
public class DBHelper
{
public DBHelper()
{
}
public DataTable GetTable(string SPName, Dictionary<string, object> SPParamWithValues)
{
DataTable dataTable = new DataTable();
//SqlCommand cmd;
//SqlDataAdapter adapter;
//SqlConnection conn;
SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter adapter = new SqlDataAdapter();
conn = Provider.GetConnection();
conn.Open();
//open DB connection
cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = conn;
cmd.CommandText = SPName;
foreach (KeyValuePair<string, object> paramValue in SPParamWithValues)
{
cmd.Parameters.AddWithValue(paramValue.Key, paramValue.Value);
}
adapter = new SqlDataAdapter(cmd);
adapter.Fill(dataTable);---Procedure or function spuserdata has too many arguments specified.
return dataTable;
}
}
here is my stored procedure ,as for i know this error is because
when we are specifying more parameters in your c# code than our stored procedure accepts..but i dont understand what are the extra parameters which i add
and here is my stored proc ::
create proc spuserdata
@id int
AS
select decription,url from tb_userdata inner join tb_userlogin on tb_userdata.uidfromtb1=tb_userlogin.id
where tb_userlogin.id=@id
how an i resolve this
Thnaks and Regards
Reply
Answers (
9
)
.Net Certification related
MVC