use ASP
go
create proc test
(
@name varchar(50),
@Surname varchar(50),
@usern varchar(50)
)
as
update Login
set Name = @name, Surname = @Surname
Where Username = @usern
go
hi just see that whether blank record is there or not one possibility may be mycmd.Parameters.AddWithValue("@usern",Request.Form["Username"].Trim()); mycmd.Parameters.AddWithValue("@name", TextBoxname.Text.ToString().Trim()); Anil
Ndamu
Member
59 Points
259 Posts
What's wrong with this code?
Nov 12, 2012 12:40 PM|LINK
use ASP
go
create proc test
(
@name varchar(50),
@Surname varchar(50),
@usern varchar(50)
)
as
update Login
set Name = @name, Surname = @Surname
Where Username = @usern
go
asp:
SqlCommand mycmd = new SqlCommand();
try
{
sqlconb.Open();
mycmd = new SqlCommand("test", sqlconb);
mycmd.CommandType = CommandType.StoredProcedure;
mycmd.Parameters.AddWithValue("@usern",Request.QueryString["Username"].Trim());
mycmd.Parameters.AddWithValue("@name", TextBoxname.Text.ToString().Trim());
mycmd.Parameters.AddWithValue("@surname", TextBoxsurname.Text.ToString().Trim());
mycmd.ExecuteNonQuery();
}
catch (SqlException ex)
{
Response.Write(ex);
}
sqlcon.Close();
}
This code has to update the detail of a user
adeelehsan
All-Star
18319 Points
2746 Posts
Re: What's wrong with this code?
Nov 12, 2012 12:52 PM|LINK
What is happening? are you getting some errors? or the code is not doing updates?
MCPD ASP.NET 4.0 and 3.5, MCTS WSS, MOSS, SharePoint 2010, MCT
Microsoft Community Contributor Award 2011
Ndamu
Member
59 Points
259 Posts
Re: What's wrong with this code?
Nov 12, 2012 12:57 PM|LINK
not updating at all
spapim
Contributor
2522 Points
376 Posts
Re: What's wrong with this code?
Nov 12, 2012 01:07 PM|LINK
Try replacing the line below:
mycmd = new SqlCommand("test", sqlconb);by
mycmd.Connection = sqlconb; mycmd.CommandText = "test";Hope this helps.
www.imobiliariasemsuzano.com.br
vijayst
All-Star
16558 Points
3216 Posts
Microsoft
Re: What's wrong with this code?
Nov 12, 2012 01:09 PM|LINK
A few questions that I can think of:
http://liteblog.codeplex.com
Ndamu
Member
59 Points
259 Posts
Re: What's wrong with this code?
Nov 12, 2012 01:11 PM|LINK
everything is right...nothing diff....same db, and same everything
Ndamu
Member
59 Points
259 Posts
Re: What's wrong with this code?
Nov 12, 2012 01:12 PM|LINK
that's how it was the first time...and it didn't work either
markfitzme
Star
14495 Points
2243 Posts
Re: What's wrong with this code?
Nov 12, 2012 01:27 PM|LINK
Try re-ordering the code so that you are adding the parameters in the exact same order that they are input into the stored procedure.
mycmd.Parameters.AddWithValue("@name", TextBoxname.Text.ToString().Trim()); mycmd.Parameters.AddWithValue("@surname", TextBoxsurname.Text.ToString().Trim()); mycmd.Parameters.AddWithValue("@usern",Request.QueryString["Username"].Trim());Ndamu
Member
59 Points
259 Posts
Re: What's wrong with this code?
Nov 12, 2012 01:49 PM|LINK
that too doesn't work....I've tried code working in vb and C#, in other pages it works...but not on this one
Anil Srivast...
Member
442 Points
292 Posts
Re: What's wrong with this code?
Nov 12, 2012 01:53 PM|LINK