Explicit Data Typing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KodeKrazy
    New Member
    • Mar 2008
    • 32

    Explicit Data Typing

    When I try to use LINQ to SQL, I get the following error:

    "Data type(s) of the type parameter(s) in method 'Public Sub InsertAllOnSubm it(Of TSubEntity As TEntity)(entiti es As System.Collecti ons.Generic.IEn umerable(Of TSubEntity))' cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error."

    Where do I need to specify the data types explicitly? In my
    Code:
    DB.Items.InsertAllOnSubmit(newCatItem)
    statement, or where I declare the variables? (Already typed everything to match my SQL DB in the variable declarations, so if that's correct, I did something wrong)

    KK
  • daniel aristidou
    Contributor
    • Aug 2007
    • 494

    #2
    Ok i think the isue is the newcatitem
    Can u post the code that sets this variable?

    Comment

    • KodeKrazy
      New Member
      • Mar 2008
      • 32

      #3
      Code:
      Option Infer On
      Option Strict On
      
      Imports System.Collections.Generic
      Imports System.Data
      Imports System.Data.Linq
      Imports System.Data.Linq.Mapping
      Imports System.Data.Linq.SqlClient
      Imports System.IO
      Imports System.Linq
      Imports System.Linq.Expressions
      Imports System.Reflection
      
      Public Class clsLINQ_Procs
        Private DB As CatDataClassesDataContext
        Public pag As String    ' Page
      
        Public Function AddCat() As Boolean
      
           pag = CType(frmMain.dgvItems.Rows(i).Cells.Item(38).Value.ToString, String)
      
           Dim newCatItem = New Item With {.Page = CType(pag, String)}
      
           DB.Items.InsertAllOnSubmit(newCatItem)
           DB.SubmitChanges() 
      
           Return AddCat=True
      
        End Function
      End Class
      There are quite a few other variables but in the interest of simplicity all the other variables are typed and declared in the same manner.

      TIA,

      KK

      Comment

      • KodeKrazy
        New Member
        • Mar 2008
        • 32

        #4
        Originally posted by KodeKrazy
        Code:
        Option Infer On
        Option Strict On
        
        Imports System.Collections.Generic
        Imports System.Data
        Imports System.Data.Linq
        Imports System.Data.Linq.Mapping
        Imports System.Data.Linq.SqlClient
        Imports System.IO
        Imports System.Linq
        Imports System.Linq.Expressions
        Imports System.Reflection
        
        Public Class clsLINQ_Procs
          Private DB As CatDataClassesDataContext
          Public pag As String    ' Page
        
          Public Function AddCat() As Boolean
        
             pag = CType(frmMain.dgvItems.Rows(i).Cells.Item(38).Value.ToString, String)
        
             Dim newCatItem = New Item With {.Page = CType(pag, String)}
        
             DB.Items.InsertAllOnSubmit(newCatItem)
             DB.SubmitChanges() 
        
             Return AddCat=True
        
          End Function
        End Class
        There are quite a few other variables but in the interest of simplicity all the other variables are typed and declared in the same manner.

        TIA,

        KK
        Not sure why it is putting all the space in the word "Value" but it's not there in my code. Just an FYI... kk

        Comment

        • KodeKrazy
          New Member
          • Mar 2008
          • 32

          #5
          Still getting the error, still don't know why...

          Comment

          Working...