Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Error after insert dataError after insert data
Previous
 
Next
New Post
1/9/2009 6:36 AM
 

Hi,

can anyone know what mean of "Exception has been thrown by the target of an invocation"?

1st, drag the Company table and store procedure into dbml file

then in my LinqDataSource1_Inserting method is normal code

and inside LinqDataSource1_Inserted method:


            Dim cp As New LinqAdvanceRegisterDataContext
            
            Dim tempCompany As New Company
            tempCompany.CompanyID = cp.P_GetLastRecordOfCompany().Last.CompanyID
            tempCompany.Supervisor1 = cp.P_GetLastRecordOfCompany().Last.Supervisor1
            tempCompany.S1Email = cp.P_GetLastRecordOfCompany().Last.S1Email
            tempCompany.S1Phone = cp.P_GetLastRecordOfCompany().Last.S1Phone

            tempCompany.Supervisor2 = cp.P_GetLastRecordOfCompany().Last.Supervisor2
            tempCompany.S2Email = cp.P_GetLastRecordOfCompany().Last.S2Email
            tempCompany.S2Phone = cp.P_GetLastRecordOfCompany().Last.S2Phone


            Dim aa As New LinqAdvanceRegisterDataContext
            If tempCompany.Supervisor1.Trim.Length > 0 Then
                aa.P_AddSupervisor(tempCompany.CompanyID, tempCompany.Supervisor1, tempCompany.S1Phone, CType(formView1.FindControl("txtS1Fax"), TextBox).Text, tempCompany.S1Email)
            End If

            If tempCompany.Supervisor2.Trim.Length > 0 Then
                aa.P_AddSupervisor(tempCompany.CompanyID, tempCompany.Supervisor2, tempCompany.S2Phone, CType(formView1.FindControl("txtS2Fax"), TextBox).Text, tempCompany.S2Email)
            End If

            Response.Redirect(NavigateURL(PortalSettings.HomeTabId))

 

and because cannot cast from cp.P_GetLastRecordOfCompany() into company type, so i do that way
the data is success insert into database, but it appear the error, even i restart the page~

help~~~

 

 
New Post
1/10/2009 1:04 PM
 

It looks like you are are doing a bit more work than you really need to.  But since you have already created your SP's then I guess you can use them otherwise all you would have to do is this.

Dim sup1 As New Supervior (or whatever your table name is you are inserting into in your P_AddSupervisor sp)
            sup1.CompanyID = cp.P_GetLastRecordOfCompany().Last.CompanyID
            sup1.Supervisor1 = cp.P_GetLastRecordOfCompany().Last.Supervisor1
            sup1.S1Email = cp.P_GetLastRecordOfCompany().Last.S1Email
            sup1.S1Phone = cp.P_GetLastRecordOfCompany().Last.S1Phone
            sup1.S1Email = cp.P_GetLastRecordOfCompany().Last.S1Fax

If Not sup1.CompanyID Is Nothing Then
cp.Company.InsertOnSubmit(sup1)
cp.SubmitChanges()
End If


View Brenden Kehren's profile on LinkedIn
 
New Post
1/12/2009 12:27 PM
 
thank for answer, but i got another problem, that is "Cannot insert explicit value for identity column in table 'CompanySupervisor' when IDENTITY_INSERT is set to OFF." so how i solve using the non sql code?
 
New Post
1/12/2009 7:29 PM
 

Sounds like a property on a field in SQL Server needs to be set.  You can set this property in the GUI or within SQL code. 


View Brenden Kehren's profile on LinkedIn
 
New Post
1/14/2009 1:46 AM
 

how to do it?

im try to use some method:

cp.ExecuteCommand("set IDENTITY_INSERT dbo.CompanySupervisor ON")   <-this is using the code
cp.P_Insertdata_ON()   <- this is create a SP and run it

but it seem not work, the error still same...

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Error after insert dataError after insert data


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out