Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Proper custom UPDATE query in SQL database connection with two tables to enable "edit item links" in Data View?

$
0
0

Hi,

On Sharepoint Designer 2007, I'm currently trying to create a database connection that uses two different tables from my database (Users and UserDetails) for use in the Data View web parts on my Sharepoint internal site. I want the tables from the database to show in one Data View table and enable the edit/insert/delete links you can toggle in the Data View Properties->Editing window.

I have the SELECT query working- it looks like this:

SELECT U.lastname , U.firstname , U.username , U.email , U.password , D.project , D.floor , D.unit_id , D.phone

FROM Users AS U INNER JOIN UserDetails AS D ON U.username = D.username 

and it allows me to display the info from the tables in my Data View, however, it won't accept my UPDATE query and allow me to display/use the edit item links (Editing tab in the Data View Properties). Here's my UPDATE query- It works perfectly on a separate .aspx page I have  (Visual Studio 2008) in that it allows me to update the database with user input (with different tables) but Sharepoint refuses to accept it (it keeps saying the edit/delete/insert link options are unavailable because the data source query does not include the primary key field(s)- which I know I included[the primary key is Username on both tables]-a CHAR value).

BEGIN TRANSACTION

UPDATE Users

SET lastname = @lastname, firstname=@firstname, email=@email, password=@password, username=@username 

WHERE username=@original_username AND lastname=@original_lastname   

UPDATE UserDetails

SET project=@project, floor=@floor, unit_id=@unit_id, phone=@phone

WHERE username=@original_username

COMMIT

I have also tried an UPDATE query with a JOIN like the SELECT query instead of the TRANSACTION thing.

Any ideas on how make this work. I want to be able to update/edit both tables in the same Data View. Thanks.




Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>