Asked by:
Error using collection classes...

Question
-
Go through my code....
public List<Remarks1> fillRemarks1List(RemarksRequest oei)
{
List<Remarks1> mylist = new List<Remarks1>();
SqlConnection sqlConn = new SqlConnection(strConn);
sqlConn.Open();
SqlCommand commInfo = new SqlCommand();
commInfo.CommandType = CommandType.StoredProcedure;
commInfo.CommandText = "dbo.SPQueryRemList";
commInfo.Connection = sqlConn;
commInfo.Parameters.Add(new System.Data.SqlClient.SqlParameter("@reqNo", System.Data.SqlDbType.Char, 20));
commInfo.Parameters["@reqNo"].Value = "0200000458";//oei.reqNo1.ToString().Trim();
commInfo.Parameters.Add(new System.Data.SqlClient.SqlParameter("@lgnId", System.Data.SqlDbType.Char, 10));
commInfo.Parameters["@lgnId"].Value = oei.loginid.ToString().Trim();
SqlDataReader rdr4;
try
{
rdr4 = commInfo.ExecuteReader();
while (rdr4.Read())
{
mylist.Add(new Remarks1(rdr4.GetString(7).Trim(), rdr4.GetString(8).Trim(), rdr4.GetString(0).Trim(), rdr4.GetString(5).Trim()));
}
rdr4.Close();
}
catch (Exception ex)
{
}
finally
{
commInfo.Dispose();
}
sqlConn.Close();
return mylist;
}
________________________________________________________________________________
MY ISERVICE :
-------------
[OperationContract]
[WebInvoke(Method = "POST",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "remarksList")]
List<Remarks1> fillRemarks1List(RemarksRequest oei);
________________________________________________________________________________
HERE IS MY AJAX CALL TO USE THE SERVICE:
----------------------------------------
urlToHandler = 'http://localhost/WcfService/Service1.svc/remarksList';
var tempyear="";
$.ajax({
url: urlToHandler,
data:JSON.stringify({oei:{"loginid":userid}}),
type: 'POST',
dataType:"json",
contentType: 'application/json',
success: function(data) {
alert(data.fillRemarksListResult);
$.each(data.fillRemarksListResult,function(key,val){
});
},
error: function(data, status, jqXHR) {
alert('There was an error.');
}
}); // end $.ajax
});
I have the following errors...
(rdr4).Depth threw an exception of type (System.InvalidOperationException)
(rdr4).FieldCount threw an exception of type (System.InvalidOperationException)
(rdr4).Hasrows threw an exception of type (System.InvalidOperationException)
I need to populate those remarks in my html page !!
- Moved by Mike Feng Friday, January 25, 2013 1:55 AM
Thursday, January 24, 2013 5:28 AM
All replies
-
I dont really get what the error is? What is the ajax result? Does the server code execute wihtout exceptions? What colelction error are you talking about?
Anze Javornik
Thursday, January 24, 2013 10:47 PM -
Hi Praveen,
Welcome to the MSDN Forum.
Please try to ask this issue on asp.net forum: http://forums.asp.net/
Thank you.
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.Friday, January 25, 2013 1:53 AM -
i have used list collection..it throws those exceptions...
and ajax results i dont get..it doesnot pass throught the success block..it goes to the error block
Friday, January 25, 2013 6:08 AM -
okie..thnk uFriday, January 25, 2013 6:08 AM