Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 910483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:03:08+00:00 2026-05-15T17:03:08+00:00

Software used: Visual studio 2008 professional with services pack 1 Sql Server 2005 Standard

  • 0

Software used:

Visual studio 2008 professional with services pack 1
Sql Server 2005 Standard Edition (9.00.4266.00)
Windows XP SP3

I have these 3 tables:

    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[Table_2](
        [table2id] [int] IDENTITY(1,1) NOT NULL,
        [table2filler] [varchar](max) NULL,
     CONSTRAINT [PK_Table_2] PRIMARY KEY CLUSTERED 
    (
        [table2id] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Table_1](
        [table1id] [int] IDENTITY(1,1) NOT NULL,
        [table1guid] [uniqueidentifier] NOT NULL,
     CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED 
    (
        [table1id] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    CREATE UNIQUE NONCLUSTERED INDEX [IX_Table_1] ON [dbo].[Table_1] 
    (
        [table1guid] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[Table_3](
        [tableguid] [uniqueidentifier] NOT NULL,
        [table2id] [int] NOT NULL,
        [table3filler] [varchar](max) NULL,
     CONSTRAINT [PK_Table_3] PRIMARY KEY CLUSTERED 
    (
        [tableguid] ASC,
        [table2id] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO
    ALTER TABLE [dbo].[Table_3]  WITH CHECK ADD  CONSTRAINT [FK_Table_3_Table_1] FOREIGN KEY([tableguid])
    REFERENCES [dbo].[Table_1] ([table1guid])
    ON DELETE CASCADE
    GO
    ALTER TABLE [dbo].[Table_3] CHECK CONSTRAINT [FK_Table_3_Table_1]
    GO
    ALTER TABLE [dbo].[Table_3]  WITH CHECK ADD  CONSTRAINT [FK_Table_3_Table_2] FOREIGN KEY([table2id])
    REFERENCES [dbo].[Table_2] ([table2id])
    ON DELETE CASCADE
    GO
    ALTER TABLE [dbo].[Table_3] CHECK CONSTRAINT [FK_Table_3_Table_2]
    GO

    INSERT INTO [dbo].[Table_2]
               ([table2filler])
         VALUES
               ('test')
    print 'table2id:'
    print scope_identity()

    GO

    declare @guid uniqueidentifier
    set @guid=newid()
    print 'table1guid:'
    print @guid

    INSERT INTO [dbo].[Table_1]
           ([table1guid])
     VALUES
           (@guid)

    GO

now open a new web apps project, create a new dbml and drag&drop these 3 tables

now just put that code in a webpage codebehind

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim test As New Table_3

    Dim db As New DataClasses1DataContext

    test.table2id = 1
    test.tableguid = New Guid("guid from table 1")
    test.table3filler = "a"

    db.Table_3s.InsertOnSubmit(test)
    db.SubmitChanges()

End Sub

and run it

you will get an invalid cast error

only way so far for me to be able to run that code is to remove the link between the table inside the DBML

is there a way to do that insert without removing the link between the tables?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:03:08+00:00Added an answer on May 15, 2026 at 5:03 pm

    ok, it’s in fact a bug with .net 3.5 and fixed with .net 4.0

    but there is a hotfix, see detail here

    everything work like it should after that hotfix is installed

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using SQL Server Express edition for my application (Visual Studio 2010 Ultimate,
Here is the setup: I run Windows 7, Visual Studio 2008 and need to
I have a Visual Studio Solution with 5 WCF services. They all are in
I've created a software that is used a SQL database. (With VS2008 SP1 &
This is on a 64 bit Windows Machine, also running Visual Studio 2010. A
I just installed 'Visual C# 2008 Express Edition' and 'Visual Web Developer 2008 Express
I just discovered the imagemap control in Visual Studio 2008. I'm familiar with the
How does one disable script debugging with Visual Studio 2010? For VS2008 I used:
I have a question regarding Visual Studio 2010 publish feature which is used after
I used the same software used here http://us.gn.bartal.org/ to create a fixed width/height treemap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.