Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Aug 16, 2010 09:24 AM|LINK
Hy guys. I try to connect my database for so long so i wrote two type of codes. Let's discuse first on.
I have database called PhoneDirectory.
It have only one table named Residents.
I have button wiht ID="Button1".
I want when i click this button to see all of my residents.
I want to see the result in DetailsView and to be able to edin, delete and add new resident.
First try with SqlDataSource so i wrote this:
<asp:SqlDataSource ID="Resident Details" runat="server" ProviderName="System.Data.SqlClient" ConnectionStrings="<%$ ConnectionStrings:ThisIsTheConnection%>"
SelectCommand = "SELECT * FROM Resident "
UpdateCommand = "UPDATE Resident SET FNAME=@FNAME, LNAME=@LNAME, MobileNum=@MobileNum," +
"HomeNum=@HomeNum, OfficeNum=@OfficeNum, FaxNum=@FaxNum" +
"WHERE FNAME=@original_FNAME AND LNAME=@original_LNAME AND MobileNum=@original_MobileNum" +
"HomeNum=@original_HomeNum AND OfficeNum=@original_OfficeNum AND FaxNum=@original_FaxNum"
InsertCommand = "INSERT INTO Resident FNAME, LNAME, MobileNum, HomeNum, OfficeNum, FaxNum" +
"VALUES ( '@FNAME', '@LNAME', '@MobileNum', '@HomeNum', '@OfficeNum', '@FaxNum')" +
DeleteCommand = "DELETE Resident WHERE FNAME=@FNAME, LNAME=@LNAME, MobileNum=@MobileNum," +
"HomeNum=@original_HomeNum AND OfficeNum=@original_OfficeNum AND FaxNum=@original_FaxNum" >
For the DetailsView - >
<asp:DetailsView ID="Resident Details" runat="server" Height="50px" Width="125px" DataSourceID="Resident Details">
And now i don't know how to bind all these 3 things. Please help.
P.S. I guess i miss something in SqlDataSource like Parameters but i'm not sure what to add.
I use Beginning ASP.NET 3.5 in C# 2008 From Novice to Professional, Second Edition for this.