I need some help here. I'll try to explain what I need as best as I can. Let says that I have 1 page website in C#. I have a table called Employee With one colum called emplyee name. On the webpage I have a text box, button, and a label. The end user
enters in a name in the text box. Than clicks on a button. I what to manually search the table to see if the name is already in use. if so it will display a message using the lable. If its not in use than it will add the information to the database. Than
it will display a message using the label letting the end user know that the data was saved. Now I do have a contactionstring in the web.config file. Please keep it sample. please help.
Okay Thank., Now what about the code behind aspx page for the button to connect to SQL to run the stored procedure. Let say that I have a connectionString in my Web.config file named MYSQLDB. Give me an exsample of a Default.aspx, Default.aspx.cs (please
include namespaces that are being used) that has 1 textbox1, Lable1, Button1. Plus a full script layout of the stored procedure. The only reason why I'm asking is so that I can study it and use it thru out my website.
Dmusselman
0 Points
3 Posts
ASP.net and SQL Server 2008 Manually coded.
Jul 29, 2010 07:57 PM|LINK
I need some help here. I'll try to explain what I need as best as I can. Let says that I have 1 page website in C#. I have a table called Employee With one colum called emplyee name. On the webpage I have a text box, button, and a label. The end user enters in a name in the text box. Than clicks on a button. I what to manually search the table to see if the name is already in use. if so it will display a message using the lable. If its not in use than it will add the information to the database. Than it will display a message using the label letting the end user know that the data was saved. Now I do have a contactionstring in the web.config file. Please keep it sample. please help.
nizam133
Contributor
3538 Points
638 Posts
Re: ASP.net and SQL Server 2008 Manually coded.
Jul 30, 2010 08:33 AM|LINK
you can write following sql query in your stored procedure,
if exists (select 1 from Employee where EmployeeName = @empName)
select 0 as empExists
else
begin
insert into Employee values (employeeName, all your other columns)
select 1 as RecordInserted
end
Dmusselman
0 Points
3 Posts
Re: ASP.net and SQL Server 2008 Manually coded.
Jul 30, 2010 03:25 PM|LINK
Okay Thank., Now what about the code behind aspx page for the button to connect to SQL to run the stored procedure. Let say that I have a connectionString in my Web.config file named MYSQLDB. Give me an exsample of a Default.aspx, Default.aspx.cs (please include namespaces that are being used) that has 1 textbox1, Lable1, Button1. Plus a full script layout of the stored procedure. The only reason why I'm asking is so that I can study it and use it thru out my website.
Thanks, Darrell
Hong-Gang Ch...
All-Star
74696 Points
6768 Posts
Re: ASP.net and SQL Server 2008 Manually coded.
Aug 04, 2010 08:40 AM|LINK
Please refer this article,
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executescalar.aspx
If you have any feedback about my replies,please contactmsdnmg@microsoft.com.
Microsoft One Code Framework
Dmusselman
0 Points
3 Posts
Re: ASP.net and SQL Server 2008 Manually coded.
Aug 04, 2010 03:20 PM|LINK
Thank you very much thats what I been looking for. Thank you everyone for y'alls help.