|
OK I am supplying my code with stored proc here:
My stored proc:
USE [UniqueCorp]
GO
/****** Object: StoredProcedure [dbo].[uspUpdateUser_Step2] Script Date: 06/05/2012 12:12:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[uspUpdateUser_Step2]
@userID uniqueidentifier,
@Username nvarchar(50),
@CompanyName nvarchar(50),
@Address nvarchar(100),
@Country nvarchar(50),
@State nvarchar(50) = '',
@City nvarchar(50) = '',
@MobileNo nvarchar(50) = '',
@TelephoneNo nvarchar(50) = '',
@Password nvarchar(50)
AS
set nocount on;
IF Exists (SELECT [ID] FROM dbo.Users WHERE [ID] = @userID)
begin
update dbo.Users
set
UserName=@Username,
CompanyName=@CompanyName,
[Address]=@Address,
Country=@Country,
[State]=@State,
City=@City,
Mobileno=@MobileNo,
TelephoneNo=@TelephoneNo,
Password=@Password
WHERE [ID] = @userID
end
GO
and the code behind is this.......
public static int AddUpdateUser(Users user)
{
SqlParameter prmUserId = new SqlParameter("@userID", SqlDbType.UniqueIdentifier);
prmUserId.Value = user.ID;
SqlParameter prmUsername = new SqlParameter("@Username", SqlDbType.NVarChar, 50);
prmUsername.Value = user.UserName;
SqlParameter prmCompanyName = new SqlParameter("@CompanyName", SqlDbType.NVarChar, 50);
prmUsername.Value = user.CompanyName;
SqlParameter prmAddress = new SqlParameter("@Address", SqlDbType.NVarChar, 100);
prmUsername.Value = user.Address;
SqlParameter prmCountry = new SqlParameter("@Country", SqlDbType.NVarChar, 50);
prmUsername.Value = user.Country;
SqlParameter prmState = new SqlParameter("@State", SqlDbType.NVarChar, 50);
prmUsername.Value = user.State;
SqlParameter prmCity = new SqlParameter("@City", SqlDbType.NVarChar, 50);
prmUsername.Value = user.City;
SqlParameter prmMobileNo = new SqlParameter("@MobileNo", SqlDbType.Int, 50);
prmUsername.Value = user.MobileNo;
SqlParameter prmTelephoneNo = new SqlParameter("@TelephoneNo", SqlDbType.Int, 50);
prmUsername.Value = user.TelephoneNo;
SqlParameter prmPassword = new SqlParameter("@Password", SqlDbType.NVarChar, 50);
prmUsername.Value = user.Password;
return DataAccessObject.Execute("uspUpdateUser_Step2",prmUserId, prmUsername, prmCompanyName, prmAddress, prmCountry, prmState, prmCity, prmMobileNo, prmTelephoneNo,prmPassword);
}
Please help me the problem is still there...
Procedure or function expects parameter @Username That was not supplied.....
But i debug and confirm dat value is gone to the parameter @Username.So now i hav no idea about this ....
|
|
|
|
|
Firstly, this is a database problem and nothing to do with ASP.NET, so it is in the wrong forum. Secondly, you have given no indication where the error occurs. Thirdly, please use the correct <pre> tags around your code so it is readable, like this:
USE [UniqueCorp]
GO
SET ANSI_NULLS ON
GO
...
|
|
|
|
|
we have to assign default value as NULL
Create Procedure Sp_name
@Input1 varchar(100)=NULL
AS
BEGIn
//main Code
END
|
|
|
|
|
That sounds like a sql parameter your supplying is null, empty or nothing.
where @value is empty.
value=@value,
But like Richard said, you should walk your code, or show some code so we know what your taking about, or just Google it.
|
|
|
|
|
OK I am supplying my code with stored proc here:
My stored proc:
USE [UniqueCorp]
GO
/****** Object: StoredProcedure [dbo].[uspUpdateUser_Step2] Script Date: 06/05/2012 12:12:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[uspUpdateUser_Step2]
@userID uniqueidentifier,
@Username nvarchar(50),
@CompanyName nvarchar(50),
@Address nvarchar(100),
@Country nvarchar(50),
@State nvarchar(50) = '',
@City nvarchar(50) = '',
@MobileNo nvarchar(50) = '',
@TelephoneNo nvarchar(50) = '',
@Password nvarchar(50)
AS
set nocount on;
IF Exists (SELECT [ID] FROM dbo.Users WHERE [ID] = @userID)
begin
update dbo.Users
set
UserName=@Username,
CompanyName=@CompanyName,
[Address]=@Address,
Country=@Country,
[State]=@State,
City=@City,
Mobileno=@MobileNo,
TelephoneNo=@TelephoneNo,
Password=@Password
WHERE [ID] = @userID
end
GO
and the code behind is this.......
public static int AddUpdateUser(Users user)
{
SqlParameter prmUserId = new SqlParameter("@userID", SqlDbType.UniqueIdentifier);
prmUserId.Value = user.ID;
SqlParameter prmUsername = new SqlParameter("@Username", SqlDbType.NVarChar, 50);
prmUsername.Value = user.UserName;
SqlParameter prmCompanyName = new SqlParameter("@CompanyName", SqlDbType.NVarChar, 50);
prmUsername.Value = user.CompanyName;
SqlParameter prmAddress = new SqlParameter("@Address", SqlDbType.NVarChar, 100);
prmUsername.Value = user.Address;
SqlParameter prmCountry = new SqlParameter("@Country", SqlDbType.NVarChar, 50);
prmUsername.Value = user.Country;
SqlParameter prmState = new SqlParameter("@State", SqlDbType.NVarChar, 50);
prmUsername.Value = user.State;
SqlParameter prmCity = new SqlParameter("@City", SqlDbType.NVarChar, 50);
prmUsername.Value = user.City;
SqlParameter prmMobileNo = new SqlParameter("@MobileNo", SqlDbType.Int, 50);
prmUsername.Value = user.MobileNo;
SqlParameter prmTelephoneNo = new SqlParameter("@TelephoneNo", SqlDbType.Int, 50);
prmUsername.Value = user.TelephoneNo;
SqlParameter prmPassword = new SqlParameter("@Password", SqlDbType.NVarChar, 50);
prmUsername.Value = user.Password;
return DataAccessObject.Execute("uspUpdateUser_Step2",prmUserId, prmUsername, prmCompanyName, prmAddress, prmCountry, prmState, prmCity, prmMobileNo, prmTelephoneNo,prmPassword);
}
Please help me the problem is still there...
Procedure or function expects parameter @Username That was not supplied.....
But i debug and confirm dat value is gone to the parameter @Username.So now i hav no idea about this ....
|
|
|
|
|
I'm just using this one as an example only, it's not the problem.
The error message you got basically says that one of your parameters is null or nothing, and that a valid value is required in order to convert the value to a qualified parameter.
prmUsername.Value = user.Address; <- One of these values is null or nothing in your list of parameters, or is the wrong format for nvarchar.
If you wrap your code in the try, catch, you can trap the sql exception message, and it will tell you which parameter is the issue.
catch ex as sqlexception
|
|
|
|
|
The function or the Procedure is having some Parameters that are not been provided by your code while making call to that procedure.
Note: Signature of Fucntion/Procedure while Defining and While Declaring the fucntion donot matches.
- Happy Coding -
Vishal Vashishta
|
|
|
|
|
My Understanding [Please correct me if I am wrong]
The input validation is the mainly validating whether the controls are sending correct input for precessing or not.
Business rule is more specific rules like "if your order is less than certain minimum required order level then it will not be accepted and this minimum required order level will be calculated based on your previous records".
My belief [Please correct me if I am wrong]
The input validation is a perfect candidate that should be done on client side i.e. javascript but since someone can bypass the javascript it should the done on server side too. The business rules should be on the server side since there are/might be a lot of variables that will be considered.
Question:
The question now is, should we duplicate all the code for business rules on client side too just for the sake of having better responsiveness (I am aware of all the AJAX and async stuff but assuming that cannot be used). I mean someone got carried away and tell you that you take all the variables from DB, put them in hidden fields and then do all the business rule logic in javascript using these hidden field values on client side(even when this is being done on server side already). Now, to me this doesn't sound right. why should be duplicate all the logic just for the sake of having better responsiveness?
Every now and then say, "What the Elephant." "What the Elephant" gives you freedom. Freedom brings opportunity. Opportunity makes your future.
|
|
|
|
|
Rahul Rajat Singh wrote: Now, to me this doesn't sound right. why should be duplicate all the logic just for the sake of having better responsiveness?
Because your sitting in an office with the server located within a mile or Kilometer of your desk. You don't see the slow response and transmission times that a customer located several hundred miles away sees.
If you validate as many values as you can client side, the customer can fill out the form correctly, and make 1 postback to the server, resulting in a single successful transaction.
If you keep validating server side, it will result in several postbacks until the customer gets it rights, increasing unnecessary bandwidth by 400% or more.
Validating business rules client side gets a bit tricky, unless the business rules are simple and basic. In your javascript, you would need a way to fetch the rule via web service, or have all the rules prewritten, and make a switch to select the correct rule and run it.
[EDIT]
Rahul Rajat Singh wrote: put them in hidden fields and then do all the business rule logic in javascript using these hidden field values on client side
For a minimum value, using a hidden textbox with the minimum value in it would be handy to validate against on the client side. For minimum values, we just change the initial qty to the minimum value, and change the qty range from 1 to 100 to 5 to 100.
|
|
|
|
|
give me one example for globalization concept in asp.net...
|
|
|
|
|
|
|
Follow:
<a href="http://www.c-sharpcorner.com/uploadfile/santhi.m/globalizationusingasp.net11262005072116am/globalizationusingasp.net.aspx">http://www.c-sharpcorner.com/uploadfile/santhi.m/globalizationusingasp.net11262005072116am/globalizationusingasp.net.aspx</a>[<a href="http://www.c-sharpcorner.com/uploadfile/santhi.m/globalizationusingasp.net11262005072116am/globalizationusingasp.net.aspx" target="_blank" title="New Window">^</a>]
- Happy Coding -
Vishal Vashishta
|
|
|
|
|
I want learn asp.net and c# step by step. please give me tips to learn
|
|
|
|
|
The best book for C#:
1. C# 2010 Step by step - beginner
2. C# 4.0 in a nutshell - comprehensive coverage
for ASP.net
1. ASP.NET 4.0 Step by step
2. MCTS 70-515 self paced training kit
3. can't remember the name but a book from WROX P2P series on ASP.NET 4.0.
Some of recommendation:
Microsoft press' MCTS self paced learning kit books are awesome, do read them.
Microsoft press' Step by step series are good for beginners, do read them.
C# 4.0 in a nutshell is pretty good, read it cover to cover.
watch videos on ASP.NET website.
read the MVPs blogs (CP and MSFT)
follow code project daily religiously.
Video Tutorials:
1. "asp.net" official website contains very good videos.
2. "Lynda.com" also has some video series on asp.net but they are from very beginners perspective.
3. "Total Training" has some asp.net 2.0 videos which are pretty awesome to get to intermediate level.
4. I am snot sure about "VTC" but hopefully it might also have some videos on asp.net too.
Every now and then say, "What the Elephant." "What the Elephant" gives you freedom. Freedom brings opportunity. Opportunity makes your future.
|
|
|
|
|
In addition to answer above, CBT Nuggets also has the latest ASP.NET framework covered
The best way to learn any technology is to practice it
Always Keep Smiling.
Yours Pankaj Nikam
|
|
|
|
|
Hello,
I am trying to display an Excel file in a .aspx page that is opened from the page load event of another .aspx page via a window.open. The HTML of the .aspx page that will display the Excel is as follows...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ExcelViewer.aspx.cs" Inherits="ExcelViewer"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Excel Viewer</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
The PageLoad event of the code behind the .aspx page that will display the Excel file includes the following code:
FileInfo fi = new FileInfo(sFilePath);
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = sMIME;
Response.AddHeader("Content-Disposition", "inline; filename=" + fi.Name);
Response.WriteFile(sFilePath);
Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
File.Delete(sFilePath);
What I am finding is that the first time I try to open the Excel file with this code, I get the 'Internet Explorer cannot display the web page...Diagnose connections problems' error page. Then if I try to view the page shortly thereafter the Excel file comes up in the page just fine. Then if I try to view the page a 3rd time I get the error page again...etc. So every other time the viewing is succeeding.
Does anyone have any thoughts as to why this is only succeeding in viewing the Excel file every other time?
Edit: I have found that if my Content-Disposition is set to 'attachment', after receiving the 'Open' or 'Save' prompt and selecting 'Open' the file does open correctly every time in Excel. I would still prefer to use a disposition of 'inline' so the user does not have to be prompted each time a file is to be viewed.
Thank You.
modified 1-Jun-12 12:45pm.
|
|
|
|
|
I am not sure, but something like this has worked fine for me:
Response.AddHeader("content-disposition", "attachment; filename=GExcel.xls");
It could be case case sensitive.
// ♫ 99 little bugs in the code,
// 99 bugs in the code
// We fix a bug, compile it again
// 101 little bugs in the code ♫
|
Tell your manager, while you code: "good, cheap or fast: pick two. "
|
|
|
|
|
Hi...
I Want to show the MS Lync presence status of users in a web page for the corresponding email id's in a gridview.please help me to get this.. Am using VS 2010. Thanks in advance..
|
|
|
|
|
Hi,
Having some problems when clicking on the logout button.
After logging out when the user click the back button on the Internet explorer browser, he is redirected to the application.
I've tried to add the following codes
Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")
This works fine but when a form is submitted and the user clicks on the ie back button, he gets webpage expired. He has to click the refresh button to reload the page.
Any idea how to solve the logout problem??
Cheers
Berba
modified 1-Jun-12 9:00am.
|
|
|
|
|
Well, you can just check on page load that if user is logged in then display the page.
Otherwise redirect to login page or display alert message that please login.
There is no requirement of
Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")
Let me know if you have any doubts.
thank you.
Regards
Keyur Satyadev
|
|
|
|
|
when the users log on set a session for your users,
and check session in target pages, and when user log out just remove that session!
Session.Add("userID",ID);
Session.Remove("userID");
for checking session:
if(Session["user"]!=null)
{
}
else
{
Response.Redirect("default.aspx");
}
|
|
|
|
|
|
Try this
- Logout button event:
String pageUrl = "";
pageUrl = Request.Url.ToString();
Session.Abandon();
Response.Redirect(pageUrl);
- And in other page that need session to work try
protected void Page_Init(object sender, EventArgs e)
{
Response.Cache.SetNoServerCaching();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetExpires(new DateTime(1900, 01, 01, 00, 00, 00, 00));
}
|
|
|
|
|
When I am stepping though some code in a C#.net 2010 web form application, an exception is thrown saying a 'column name' is invalid. As far as I can tell the dbml property name is spelled the same way it is spelled in the for the column in the specificied table.. I checked the property values for this date column and it is like all the other properties for other date columns in this table.
When I comment out the column in the application, all the of rest of the linq commands work correctly.
Thus can you suggest what I should check to see what is wrong?
|
|
|
|
|