Return values are not received

I'm trying to return three values from an sp; they're returning 0 instead of the values they're s'posed to be turning. What am I doing wrong

CODE SqlConnection pctConn = new SqlConnection(ConfigurationSettings.AppSettings["pctConn"].ToString());
SqlCommand LoginCmd = new SqlCommand("sp_validateUser",pctConn);
LoginCmd.CommandType = CommandType.StoredProcedure;

SqlParameter uidParam = new SqlParameter("@uid",SqlDbType.VarChar);
SqlParameter pwdParam = new SqlParameter("@pwd",SqlDbType.VarChar);
SqlParameter errorParam = new SqlParameter("@error",SqlDbType.Int);
SqlParameter adminParam = new SqlParameter("@admin",SqlDbType.Int);
SqlParameter userIdParam = new SqlParameter("@uidReturn",SqlDbType.Int);

uidParam.Value = UserNameTB.Text;
pwdParam.Value = PasswordTB.Text;

uidParam.Direction = ParameterDirection.Input;
pwdParam.Direction = ParameterDirection.Input;
errorParam.Direction = ParameterDirection.ReturnValue;
adminParam.Direction = ParameterDirection.ReturnValue;
userIdParam.Direction = ParameterDirection.ReturnValue;


int LoginResult = int.Parse(LoginCmd.Parameters["@error"].Value.ToString());
int AdminResult = int.Parse(LoginCmd.Parameters["@admin"].Value.ToString());
int UIDResult = int.Parse(LoginCmd.Parameters["@uidReturn"].Value.ToString());

Posted On: Tuesday 27th of November 2012 10:45:49 PM Total Views:  474
View Complete with Replies

Related Messages:

Problem with return key   (267 Views)
I have a page with several controls and validation controls. If I enter text in a control ad press return it fires the validation controls instead of just tabbing to the next field. I have to use the tab key to do this. How do I make the return key act like the tab key
How to return results on button click? Resolved--   (189 Views)
Found my error...
List only returning last list of data? Overwritting!   (208 Views)
ohiostate, on 21 October 2011 - 09:37 AM, said: protected void Page_Load(object sender, EventArgs e) { //Connecting to web service, check for errors, etc foreach (LoanSummary i in membershipDetailResponse.Loan) { long loanMemberId = i.MemberId; //Response.Write("id: " + loanMemberId); int loanId = i.AccountId; //Response.Write(" loan: " + loanId); GetLoans(loanMemberId, loanId); } } } public void GetLoans(long loanMemberID, int loanId) { // connect to web service, check for errors, make sure I have a response List list = new List(); string memberidforloan = Convert.ToString(loanDetailsResponse1.MemberId); string loan = loanDetailsResponse1.Product; string opendate = Convert.ToString(loanDetailsResponse1.OriginationDate); string originalrate = Convert.ToString(loanDetailsResponse1.OriginalInterestRate); string currentpayment = Convert.ToString(loanDetailsResponse1.EffectivePayment); string currentrate = Convert.ToString(loanDetailsResponse1.Rate); string status = loanDetailsResponse1.Status; list.Add(new MemberLoans(memberidforloan, loan, opendate, originalrate, currentpayment, currentrate, status)); //list = new List(); Have the above uncomment in my code, as I read I need to create a new list object as I'm just overwriting it. Still does not fix my issue Repeater2.DataSource = list; Repeater2.DataBind(); } When I do the below code, I see all values printed to page!!! List list = new List(); list.Add(memberidforloan); list.Add(loan); list.Add(opendate); list.Add(originalrate); list.Add(currentpayment); list.Add(currentrate); list.Add(status); foreach (string c in list) { Response.Write(" ** "+c); } using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace WebApplication1 { public class MemberLoans { public string memberidforloan; public string loan; public string opendate; public string originalrate; public string currentpayment; public string currentrate; public string status; public MemberLoans(string memberidforloan, string loan, string opendate, string originalrate, string currentpayment, string currentrate, string status) { this.memberidforloan = memberidforloan; = loan; this.opendate = opendate; this.originalrate = originalrate; this.currentpayment = currentpayment; this.currentrate = currentrate; this.status = status; } public string MemberIdForLoan { get { return memberidforloan; } } public string Loan { get { return loan; } } public string OpenDate { get { return opendate; } } public string OriginalRate { get { return originalrate; } } public string CurrentPayment { get { return currentpayment; } } public string CurrentRate { get { return currentrate; } } public string Status { get { return status; } } } } Its just not adding each loan to my List. THANKS FOR ANY HELP!!!
Problem with returning the delete value in grid view 3.5   (318 Views)
people! So here is my problem, First things first i am coding in visual basic using 3.5 and visual studio 2008. I have a current datagrid returning values from a database, however because i have used a complex sql query rather than using one from query builder i cannot get the automatic delete function to work. Every time i try to use it it forces an error. I know the SQL statment i need to use is DELETE FROM aspnet_Users WHERE (UserName = @UserName) This works if i test it in query builder after asking for a username prompt. What i can't seem to do is attach this query so that when the user clicks on the delete button for a current row, it grabs the username for the user and updates the query to execute for example Delete From aspnet_Users WHERE (UserName="James12") I hope this is a simple fix if you need any more info please ask me Many return value   (222 Views)
hii. .can anybody tell me what is the return value of method how can we know that that method workout successfully
How to return value of last autonum entered   (142 Views)
I have an INSERT statement to create a new record and I would like to return the ID value from the newly created record. I believe I have to use the Scope_Identity() function but not sure how to actually write it out to my page after it's returned. NEW_PSR_SQL="INSERT INTO tbl_PSRs (PSR_Date, PSR_Text, PSR_Calc_Value, PSR_Override_Value, Is_Override) VALUES ('"&PSR_Date &"','"&PSR_Text &"'," &PSR_Calc_Value &"," &PSR_Override_Value &"," &PSR_Is_Override &") SELECT NEWID = SCOPE_IDENTITY() " set RsPSR=oConn.execute(NEW_PSR_SQL) response.write RsPSR(0) ' trying to return the last autonum from Scope_Identity() - not working The insert is working fine, but the code to write out the new ID is not working. Any ideas
Unable to return rows from dataset in code behind   (222 Views)
I have a form that dynamically builds a SQL statement off of user defined criteria. After the criteria is entered the user clicks on the Search button and the SQL statement populates a grid view table for the user to view. I have used this code in another page on this website and it works fine. When I copied it over and changed that values... something happened... and I am not really sure why it isn't working. The sQL statements are running fine. (I double checked them.) After the SQL string is created, it should call a function called GetData builds the database. It then does a row count and attaches the dataset to the grid view table as the datasource. // Bind Hay grid view datasource DataSet ds = GetData(strSQLQuery + strSortBy); // Sets the labels for sorting and paging lblSQLQuery.Text = strSQLQuery; lblSQLSort.Text = strSortBy; // **** HERE IS WHERE IT IS RETURNING 0 ROWS if (ds.Tables.Count > 0) { // If there are records returned from search criteria grdHay.DataSource = ds; grdHay.DataBind(); } else { // *** THIS IS WEHRE THE "ERROR" MESSAGE IS STEMMING FROM string script = "window.alert('Unable to connect to the database.')"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Open window", script, true); } Here is the function GetData. The exception handler never catches an exception. In other words, this runs just fine. It just isn't returning any rows.... or attaching to the dataset. (Which I guess means that it really isn't running fine at all.) DataSet GetData(string queryString) { // Retrieve the connection string stored in the Web.config file. String connectionString = ConfigurationManager.ConnectionStrings["StandleeHay"].ConnectionString; DataSet ds = new DataSet(); try { // Connect to the database and run the query. SqlConnection connection = new SqlConnection(connectionString); SqlDataAdapter adapter = new SqlDataAdapter(queryString, connection); // Fill the DataSet. adapter.Fill(ds); } catch (Exception ex) { // **** NEVER MAKES IT INTO THIS BLOCK OF CODE // The connection failed. Display an error message. string script = "window.alert('Unable to connect to the database.')"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Open window", script, true); } return ds; } I am not receiving any errors. I am just not returning any rows at the row count for the dataset. (Note that when I run the same query in SQL Server, I get data returned.) Instead, I am getting the javascript popup alert window. I am wondering why this is occuring. Any and all help will be appreciated. Thank you in advance for your help. I really apprectiate it. Really.... insert a hundred million
get return value of java script function from aspx.vb   (213 Views)
get return value of java script function from aspx.vb
Popup Not returning a value to Parent page.   (174 Views)
Popup Not returning a value to Parent page. From popup page i have a textbox & on submit i want to pass the value to a parent page hidden field, but not able to get it. this is my parent page js, var popUpObj; //Declare a global variable function popUp(url, hiddenFieldId) { popUpObj =, "Popup", "toolbar=no,scrollbars=yes,location=no" + ",statusbar=no,menubar=no,resizable=0,width=700," + "height=250,left = 300,top = 300"); popUpObj.focus(); } nd popup page js: function callParentFunc() { var lsString; lsString = document.getElementById('').value; window.opener.document.getElementById("hdComment").value = lsString window.close(); window.opener.location.reload(true); } but on parent page didnt got the values actually from parent page i open the popup & pass the hiddenfield to the popup so if hidden filed is null then textbox is blank & if user enteresin textbox & clicks submit then hidden field shud be populated & passed to paren tpage. pls help...
document.getElementById(...) returns null   (191 Views)
I have the following script:Code: function SetLabel_CB(cb) { l1 = document.getElementById(cb); }and in my code-behind, I have:Code: Dim lb As LinkButton = e.Row.FindControl("CallbackLinkButton1") lb.Attributes.Add("onMouseOver", "SetLabel_CB('LinkButton2');")I am doing a FindControl because the control is within a GridView.This doesn't work. l1 always return null. What am I doing wrong
SP always returns -1   (204 Views)
I've got the following:Code: conn.Open() Dim iCount As Integer iCount = cmd.ExecuteNonQuery() conn.Close() If iCount = 0 Then Return False Else Return True End Ifand in my SP, I have the following:Code:ALTER PROCEDURE dbo.UsersCheckDuplicate_sp ( @UserName nvarchar(256) )ASSET NOCOUNT ONSELECT * FROM aspnet_Users WHERE UserName=@UserNameIF @@ROWCOUNT = 0 RETURN 0ELSE RETURN 1But the SP always returns a -1. When I put my SP in debug, I can see that the SP steps thru' properly thru the code. But eventhough it is supposed to return a 0 or a 1, it always returns a -1 in my VB code.
published webservice on IIS7 returns no data   (165 Views)
I have published web service on IIS7 and when i have tested it , it always returns no data from database from all methods although it returns data when it is running on Visual Studio!
how make function return more values   (184 Views)
this code return one value only so how make this code return more value (ex three row from table) please help me quickly [WebMethod] public string violation_price(string no) { OleDbConnection cn = new OleDbConnection(); OleDbCommand cmd = new OleDbCommand(); OleDbDataReader dr; string name; double price; DateTime date; cn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=egover3;Data Source=HOME-WS1"; try { cn.Open(); cmd.CommandText = " select voiolation_type,violation_date,violation_price from violation" + " where vech_no =" + no; cmd.Connection = cn; dr = cmd.ExecuteReader(); if (dr.Read()) { name = Convert.ToString(dr.GetString(0)); date = Convert.ToDateTime(dr.GetDateTime(1)); price = Convert.ToDouble(dr.GetValue(2)); string date1 = date.ToString(); string price1 = price.ToString(); return "The Data are " + name + " ,price is " + price1 + " date ," + date1; } else return "the no not found"; } catch (Exception r) { return r.Message; } cn.Close(); } } This post has been edited by eclipsed4utoo: 19 February 2010 - 02:46 PM Reason for edit:: please use the code tags
Need assistance with returning first paragraph of stored text   (239 Views)
I need to format a field to show ONLY the first paragraph...This will be used for dsiplaying a teaser to an article.I have the value coming in with a lblContent.DataBind() which makes lblContent.Text = the entire article. What are some ways to get this to ONLY have the first paragrap
how to return breaks from a database   (169 Views)
!i wrote a little guestbook, so the "guest" can enter some text in a textarea what is given back in a normal problem is, that when the user enters a break, it is not overgiven in the tag area, instead of breaks i see blank spaces then,... i am using a database, too, but in there, the breaks were done. i already tried the wrap-event in the textarea, with wrap="virtual" means the breaks are stored as char in the database aswell if i am not wrong.., but it seems, the wrap-event doesnt work.maybe anyone has any idea how to return breaks out of a database
How customize the return xml by Web Service   (165 Views)
I written web service using it works fine. by running the web service i can put value and get the result. it shows the result in xml format. for eg:- admin this xml is generated by web service but i have a requirement that instead of this xml, generate a xml as we want including data. fro eg:- admin like this.(this is for only demostration) it means generate an xml according our requirement. is this possible if it is can u give me overview how this is done/ good web site related this topic.
return image or image url from the handler?   (215 Views)
I have a datagrid with a templated field that looks like the following:CODE In the handler, it runs a query to see if the employee is available, or unavailable for work and the deed result should be the display of the proper imageCODE if((Int32)cmd.ExecuteScalar() != 0) context.Response.Write("icoUnAvailable.png"); else context.Response.Write("icoAvailable.png");This isn't working. Is there a way to return the image URL from the handler, or do I have to load and display the image from within the handler
custom validator - problem returning bit/boolean in DAL   (180 Views)
I have a custom validator which does some server side validation:CODEProtected Sub cvDuplicateName_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles cvDuplicateName.ServerValidate Dim strLegalNameNew As Object = Me.txtLegalNameNew.Text Dim qta As New QueriesTableAdapter Dim objResult As Object = qta.udf_ExistsDuplicateCompanyName(strLegalNameNew) 'Dim bool As Boolean = qta.udf_ExistsDuplicateCompanyName(strLegalNameNew) ' Dim int As Integer = qta.udf_ExistsDuplicateCompanyName(strLegalNameNew) If objResult = True Then args.IsValid = "false" Else args.IsValid = "true" End If End SubThe problem is no matter what I do, objResult always is returning false and I can't figure out why. In my XSD file, the qta.udf_ExistsDuplicateCompanyName(strLegalNameNew) points to a stored prodedure that returns a bit. When I test the procedure in the XSD file interface, it shows that it returns Type Object with the value of either True or False as it should. But when I step through the code in VS debugger, objResult does not return the right value (always false). I tried makeing objResult an int and a boolean, and also changed the corresponding data return type in my stored procedure, but it didn't work..ok...I call UNCLE already.....what gives here
How do I return the name (ID) of the User Control that Raised an Event   (168 Views)
How do I return the name (ID) of the User Control that Raised an Event
TableAdapter method does not return a value. What am i doing wrong   (219 Views)
I have a TableAdapter defined that invokes a method 'RequestPasswordReset'. The RequestPasswordReset method returns a value of userid is valid crentials could be authenticated or -1 if not. When i test the fucntionality of the method in the dataset Preview Mode it works fine.but when i try to access the method through the following code, it never return any valuewhat is that i am doing wrong. 'Check with the User credentials provided and allow the user to add a new password Dim objRegistrationTableAdapter As New dsRegistrationTableAdapters.objAccountsUserProfilesTableAdapter iUserID = objRegistrationTableAdapter.RequestPasswordReset(UserName.Text, cboSecurityQuestion.SelectedValue, SecurityAnswer.Text) If iUserID > 0 Then Response.Redirect("PasswordReset.aspxUserID=" & iUserID) Else lblError.visible = True End If