Hi Guys
I already searched for one day and didn't find any solution. Unfortunately I can't update my dataset. It works when I remove the string "WHERE ID = ?" in the UpdateCommand but then it updates all the records. I think it must be something obvious which I just don't see:(
There are two tables; tblArtists and tblCountries which are connected together with a Inner Join. Now, I need the ID from the table Artists to update the dataset. How can I get it?
Here the code:
...
SelectCommand="SELECT tblArtists.ID AS IDArtists, tblArtists.ArtistName, tblArtists.FirstName, tblArtists.LastName, tblArtists.Address, tblArtists.PLZ, tblArtists.City, tblArtists.Region, tblArtists.Country_ID, tblArtists.MusicStyles, tblArtists.HomeDJ, tblArtists.Active, tblArtists.CDate, tblArtists.Description, tblCountries.ID AS IDCountries, tblCountries.Country, tblArtists.Producer, tblArtists.Picture, tblArtists.Homepage, tblArtists.Phonenumber, tblArtists.eMail FROM (tblCountries INNER JOIN tblArtists ON tblCountries.ID = tblArtists.Country_ID) WHERE (tblArtists.Active = ?) AND (tblArtists.HomeDJ = ?) AND (tblArtists.Producer = ?)"
UpdateCommand="UPDATE tblArtists SET ArtistName = ?, FirstName = ?, LastName = ?, Address = ?, PLZ = ?, City = ?, Region = ?, Country_ID = ?, MusicStyles = ?, HomeDJ = ?, Active = ?, Description = ?, Producer = ?, Picture = ?, Homepage = ?, Phonenumber = ?, eMail = ? WHERE ID = ?">
<SelectParameters>
<asp:ControlParameter ControlID="activeRadioButton" Name="Active" PropertyName="Checked" Type="Boolean"/>
<asp:ControlParameter ControlID="homedjRadioButton" Name="HomeDJ" PropertyName="Checked" Type="Boolean"/>
<asp:ControlParameter ControlID="producerRadioButton" Name="Producer" PropertyName="Checked" Type="Boolean"/>
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="ArtistName" Type="String" Size="254" />
<asp:Parameter Name="FirstName" Type="String" Size="254" />
<asp:Parameter Name="LastName" Type="String" Size="254" />
<asp:Parameter Name="Address" Type="String" Size="254" />
<asp:Parameter Name="PLZ" Type="String" Size="254" />
<asp:Parameter Name="City" Type="String" Size="254" />
<asp:Parameter Name="Region" Type="String" Size="254" />
<asp:Parameter Name="Country_ID" />
<asp:Parameter Name="MusicStyles" Type="String" Size="254" />
<asp:Parameter Name="HomeDJ" Type="Boolean" />
<asp:Parameter Name="Active" Type="Boolean" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="Producer" Type="Boolean" />
<asp:Parameter Name="Picture" Type="String" Size="254" />
<asp:Parameter Name="Homepage" Type="String" Size="254" />
<asp:Parameter Name="Phonenumber" Type="String" Size="50" />
<asp:Parameter Name="eMail" Type="String" Size="50" />
<asp:Parameter Name="original_IDArtists" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
Greetings
Pat
Hi ya,
is it used in the context of GridVIew? If so did u set the DataKeyNames of the GridView ?
<asp:gridview runat="server" id="GridView1" datasourceid="ArtistsSource"
AutoGenerateColumns="false"
DataKeyNames="original_IDArtists" AutoGenerateEditButton="true">
<columns>
<asp:boundfield datafield="ArtistName" headertext="Artist Name" />
<asp:boundfield datafield="FirstName" headertext="First Name" />
.......................
</columns>
</asp:gridview
Hope this will help,
Yani
No comments:
Post a Comment