Thursday, March 22, 2012

AdventureWorks in vwd

Goodday all

I wonder if anyone can help.

I'm trying to work through a tutorial using a sample database , Adventureworks. When I drag a table "Address" onto my page to set up a grid veiw , and start debugging , the error message reads "invalid object name Address"

On the database explorer the table has (Person) next to the name Address. This I think has something to do with the schema. I cannot get it right to change anything , no matter what I try. I have used this data base in a windows application and it works fine. No (Person ) attached to the table name.

Has anyone got any ideas.

Thanks

Rob

That is a known issue.

One workaround is to edit the ASP.Net code in the SQL Datasource similar to this:

 <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString%>" DeleteCommand="DELETE FROM[Person.Address] WHERE [AddressID] = @.AddressID" InsertCommand="INSERT INTO [Person.Address] ([AddressLine1], [AddressLine2], [City], [StateProvinceID], [PostalCode], [rowguid], [ModifiedDate]) VALUES (@.AddressLine1, @.AddressLine2, @.City, @.StateProvinceID, @.PostalCode, @.rowguid, @.ModifiedDate)" SelectCommand="SELECT * FROMPerson.Address" UpdateCommand="UPDATE [Person.Address] SET [AddressLine1] = @.AddressLine1, [AddressLine2] = @.AddressLine2, [City] = @.City, [StateProvinceID] = @.StateProvinceID, [PostalCode] = @.PostalCode, [rowguid] = @.rowguid, [ModifiedDate] = @.ModifiedDate WHERE [AddressID] = @.AddressID">

You can also open up the Configure Datasource window and select "Specify a custom SQL Statement..." instead of a table and edit the text there.

You must also refresh the schema of the Gridview. If that doesn't work, delete the GridView, add another one and connect it to the Datasource you just edited.

|||

Thanks for that . I,v nearly got it to work . I can at least see the data now. However I cannot edit the data or work with it . When I try I get this error message.

Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query.

How can I get around this?

Regards

Rob

|||

Without seeing the code it's hard to say.

No comments:

Post a Comment