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.\tWhat am I doing wrong

CODE\t\t\t\t\t\tSqlConnection pctConn = new SqlConnection(ConfigurationSettings.AppSettings["pctConn"].ToString());
\t\t\t\t\t\tSqlCommand LoginCmd = new SqlCommand("sp_validateUser",pctConn);
\t\t\t\t\t\tLoginCmd.CommandType = CommandType.StoredProcedure;
\t\t\t\t\t\t
\t\t\t\t\t\tSqlParameter uidParam = new SqlParameter("@uid",SqlDbType.VarChar);
\t\t\t\t\t\tSqlParameter pwdParam = new SqlParameter("@pwd",SqlDbType.VarChar);
\t\t\t\t\t\tSqlParameter errorParam = new SqlParameter("@error",SqlDbType.Int);
\t\t\t\t\t\tSqlParameter adminParam = new SqlParameter("@admin",SqlDbType.Int);
\t\t\t\t\t\tSqlParameter userIdParam = new SqlParameter("@uidReturn",SqlDbType.Int);

\t\t\t\t\t\tuidParam.Value = UserNameTB.Text;
\t\t\t\t\t\tpwdParam.Value = PasswordTB.Text;
\t\t
\t\t\t\t\t\tuidParam.Direction = ParameterDirection.Input;
\t\t\t\t\t\tpwdParam.Direction = ParameterDirection.Input;
\t\t\t\t\t\terrorParam.Direction = ParameterDirection.ReturnValue;
\t\t\t\t\t\tadminParam.Direction = ParameterDirection.ReturnValue;
\t\t\t\t\t\tuserIdParam.Direction = ParameterDirection.ReturnValue;

\t\t\t\t\t\tLoginCmd.Parameters.Add(uidParam);
\t\t\t\t\t\tLoginCmd.Parameters.Add(pwdParam);
\t\t\t\t\t\tLoginCmd.Parameters.Add(errorParam);
\t\t\t\t\t\tLoginCmd.Parameters.Add(adminParam);
\t\t\t\t\t\tLoginCmd.Parameters.Add(userIdParam);

\t\t\t\t\t\ttry
\t\t\t\t\t\t{
\t\t\t\t\t\t\t\tpctConn.Open();
\t\t\t\t\t\t\t\tLoginCmd.ExecuteNonQuery();
\t\t\t\t\t\t\t\tint LoginResult = int.Parse(LoginCmd.Parameters["@error"].Value.ToString());
\t\t\t\t\t\t\t\tint AdminResult = int.Parse(LoginCmd.Parameters["@admin"].Value.ToString());
\t\t\t\t\t\t\t\tint UIDResult = int.Parse(LoginCmd.Parameters["@uidReturn"].Value.ToString());
Posted On: Tuesday 27th of November 2012 10:45:49 PM Total Views:  497
View Complete with Replies

RELATED TOPICS OF ASP.NET PROGRAMMING LANGUAGE




Problem with return key

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
VIEWS ON THIS POST

285

Posted on:

Sunday 11th November 2012
View Replies!

How to return results on button click? Resolved--

Found my error...
VIEWS ON THIS POST

207

Posted on:

Sunday 11th November 2012
View Replies!

List only returning last list of data? Overwritting!

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; this.loan = 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!!!
VIEWS ON THIS POST

223

Posted on:

Thursday 15th November 2012
View Replies!

Problem with returning the delete value in grid view asp.net 3.5

people! So here is my problem, First things first i am coding in visual basic using asp.net 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
VIEWS ON THIS POST

340

Posted on:

Thursday 15th November 2012
View Replies!

Gridpanel.save() return value

hii. .can anybody tell me what is the return value of gridpanel.save method how can we know that that gridpanel.save method workout successfully
VIEWS ON THIS POST

236

Posted on:

Thursday 15th November 2012
View Replies!

How to return value of last autonum entered

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
VIEWS ON THIS POST

149

Posted on:

Friday 16th November 2012
View Replies!

Unable to return rows from dataset in code behind

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
VIEWS ON THIS POST

249

Posted on:

Friday 23rd November 2012
View Replies!

get return value of java script function from aspx.vb

get return value of java script function from aspx.vb
VIEWS ON THIS POST

229

Posted on:

Saturday 24th November 2012
View Replies!

Popup Not returning a value to Parent page.

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 = window.open(url, "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...
VIEWS ON THIS POST

194

Posted on:

Saturday 24th November 2012
View Replies!

document.getElementById(...) returns null

I have the following script:Code:\t\tfunction SetLabel_CB(cb)\t\t{\t\t\t\tl1 = document.getElementById(cb);\t\t}and in my code-behind, I have:Code:\t\t\t\t\t\t\t\tDim lb As LinkButton = e.Row.FindControl("CallbackLinkButton1")\t\t\t\t\t\t\t\tlb.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
VIEWS ON THIS POST

203

Posted on:

Sunday 25th November 2012
View Replies!

SP always returns -1

I've got the following:Code:\t\t\t\tconn.Open()\t\t\t\tDim iCount As Integer\t\t\t\tiCount = cmd.ExecuteNonQuery()\t\t\t\tconn.Close()\t\t\t\tIf iCount = 0 Then\t\t\t\t\t\tReturn False\t\t\t\tElse\t\t\t\t\t\tReturn True\t\t\t\tEnd Ifand in my SP, I have the following:Code:ALTER PROCEDURE dbo.UsersCheckDuplicate_sp\t\t(\t\t\t\t@UserName nvarchar(256)\t\t)ASSET NOCOUNT ONSELECT * FROM aspnet_Users WHERE UserName=@UserNameIF @@ROWCOUNT = 0\t\tRETURN 0ELSE\t\tRETURN 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.
VIEWS ON THIS POST

224

Posted on:

Sunday 25th November 2012
View Replies!

published webservice on IIS7 returns no data

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!
VIEWS ON THIS POST

180

Posted on:

Sunday 25th November 2012
View Replies!

how make function return more values

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
VIEWS ON THIS POST

196

Posted on:

Monday 26th November 2012
View Replies!

Need assistance with returning first paragraph of stored text

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 paragraph
VIEWS ON THIS POST

261

Posted on:

Monday 26th November 2012
View Replies!

how to return breaks from a database

!i wrote a little guestbook, so the "guest" can enter some text in a textarea what is given back in a normal tag.my 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
VIEWS ON THIS POST

183

Posted on:

Monday 26th November 2012
View Replies!

How customize the return xml by Web Service

I written web service using asp.net. 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.
VIEWS ON THIS POST

177

Posted on:

Tuesday 27th November 2012
View Replies!

return image or image url from the handler?

I have a datagrid with a templated field that looks like the following:CODE\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIn 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\t\t\t\t\t\tif((Int32)cmd.ExecuteScalar() != 0)\t\t\t\t\t\t\t\tcontext.Response.Write("icoUnAvailable.png");\t\t\t\t\t\telse\t\t\t\t\t\t\t\tcontext.Response.Write("icoAvailable.png");This isn't working.\tIs 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
VIEWS ON THIS POST

236

Posted on:

Tuesday 27th November 2012
View Replies!

custom validator - problem returning bit/boolean in DAL

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\t\t\t\tDim strLegalNameNew As Object = Me.txtLegalNameNew.Text\t\t\t\tDim qta As New QueriesTableAdapter\t\t\t\tDim objResult As Object = qta.udf_ExistsDuplicateCompanyName(strLegalNameNew)\t\t\t\t'Dim bool As Boolean = qta.udf_ExistsDuplicateCompanyName(strLegalNameNew)\t\t\t' Dim int As Integer = qta.udf_ExistsDuplicateCompanyName(strLegalNameNew)\t\t\t\tIf objResult = True Then\t\t\t\t\t\targs.IsValid = "false"\t\t\t\tElse\t\t\t\t\t\targs.IsValid = "true"\t\t\t\tEnd If\t\tEnd SubThe problem is no matter what I do, objResult always is returning false and I can't figure out why.\tIn my XSD file, the qta.udf_ExistsDuplicateCompanyName(strLegalNameNew) points to a stored prodedure that returns a bit.\tWhen 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.\tBut when I step through the code in VS debugger, objResult does not return the right value (always false).\tI 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\t
VIEWS ON THIS POST

193

Posted on:

Tuesday 27th November 2012
View Replies!

How do I return the name (ID) of the User Control that Raised an Event

How do I return the name (ID) of the User Control that Raised an Event
VIEWS ON THIS POST

175

Posted on:

Tuesday 27th November 2012
View Replies!

TableAdapter method does not return a value. What am i doing wrong

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.\t'Check with the User credentials provided and allow the user to add a new password\t\t\t\tDim objRegistrationTableAdapter As New dsRegistrationTableAdapters.objAccountsUserProfilesTableAdapter\t\t\t\tiUserID = objRegistrationTableAdapter.RequestPasswordReset(UserName.Text, cboSecurityQuestion.SelectedValue, SecurityAnswer.Text)\t\t\t\tIf iUserID > 0 Then\t\t\t\t\t\tResponse.Redirect("PasswordReset.aspxUserID=" & iUserID)\t\t\t\tElse\t\t\t\t\t\tlblError.visible = True\t\t\t\tEnd If
VIEWS ON THIS POST

230

Posted on:

Tuesday 27th November 2012
View Replies!