The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Newbie question

Last post 08-01-2008, 7:46 AM by jules140. 6 replies.
Sort Posts: Previous Next
  •  08-01-2008, 2:54 AM 10480

    Newbie question

    Hi,

     I'm currently evaluating the Trial of ES2008 (very impressed).

    However, I'm having a problem with populating a collection (code below):

    Code:
    1    esProviderFactory.Factory = New esDataProviderFactory
    2    
    6        Dim dayCountTotal As Long = DateDiff(DateInterval.Day, dtpFromDate.Value, dtpToDate.Value)
    7    
    8        Using collDTG As New BLL.BLL.SignalrefCollection
    9          For dayCount As Long = 0 To dayCountTotal + 1
    10           Dim workingDate As Date = DateAdd(DateInterval.Day, dayCount, dtpFromDate.Value).Date
    11           For hourCount As Integer = 7 To 18
    12             For minuteCount As Integer = 0 To 55 Step 5
    13               Dim currentDate As BLL.BLL.Signalref = New BLL.BLL.Signalref
    14               Dim dtg As String = String.Empty
    15               Dim signalDateTime As Date = CDate(workingDate & " " & hourCount & ":" & minuteCount)
    16   
    17               dtg = Format(workingDate.Day, "00") & Format(hourCount, "00") & Format(minuteCount, "00") & "z" & MonthName(workingDate.Month, True) & workingDate.Year.ToString.Substring(2, 2)
    18               Debug.Print(signalDateTime.ToString)
    19               currentDate.SignalDatetime = signalDateTime
    20               currentDate.SignalDtg = dtg
    21               collDTG.AttachEntity(currentDate)
    22             Next minuteCount
    23           Next hourCount
    24           collDTG.Save()
    25         Next dayCount
    26       End Using
    When the procedure gets to "collDTG.Save" (line 24), an error is throw 

    "System.NullReferenceException was unhandled
      Message="Object reference not set to an instance of an object."
      Source="EntitySpaces.Interfaces"
      StackTrace:
           at EntitySpaces.Interfaces.esConnection.get_SqlAccessType()    at EntitySpaces.Core.esEntityCollection.Save()    at DTG_Generator.Form1.btnGenerate_Click(Object sender, EventArgs e)    at System.Windows.Forms.Control.OnClick(EventArgs e)    at System.Windows.Forms.Button.OnClick(EventArgs e)    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)    at System.Windows.Forms.Control.WndProc(Message& m)    at System.Windows.Forms.ButtonBase.WndProc(Message& m)    at System.Windows.Forms.Button.WndProc(Message& m)    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)    at System.Windows.Forms.Application.Run(ApplicationContext context)    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)    at DTG_Generator.My.MyApplication.Main(String[] Args)    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)    at System.Threading.ThreadHelper.ThreadStart()
      InnerException:

    I have the references to EntitySpaces.Core and Interfaces in my project (and Imports statements).

    I definitely will buy this product if this can be resolved.

    Also, is it possible to change the default stored procedure prefix (usp_ rather than proc_)?

    Any ideas?

     Cheers

    Jules

  •  08-01-2008, 4:18 AM 10485 in reply to 10480

    Re: Newbie question

    Hi

    Obvious thing I know but have you included the relevant Entityspaces config entries in your app.config?

  •  08-01-2008, 4:25 AM 10487 in reply to 10485

    Re: Newbie question

    Hi,

    Thanks for the quick response. 

    I've got a Winforms app calling to a DLL (with the generated code in there).

    The ES2008 entries are in the app.config in the dll project (conn strings etc).

    If I move the config file to the winforms project, I get "Configuration System failed to initialize".

     Any pointers?

    Jules

     

     

  •  08-01-2008, 5:06 AM 10489 in reply to 10487

    Re: Newbie question

    Hi

    This is the setup I've just tested which works fine:

    1) DLL with entityspaces generated/custom code (nothing else).  This dll references "Entityspaces.Core" and "Entityspaces.Interfaces"

    2) Console app that references the above dll + "Entityspaces.Core", "Entityspaces.Interfaces", "Entityspaces.Loader" and my provider (which is the access one for this test - "Entityspaces.MSAccessProvider"

    3) I have an app.config file setup ONLY in my console app, setup as below

    App.Config:

    Code:
    <configuration>
    
      <configSections>
        <sectionGroup name="EntitySpaces" type="EntitySpaces.Interfaces.esConfigSettings, EntitySpaces.Core">
          <section name="connectionInfo" type="EntitySpaces.Interfaces.esConfigSettings, EntitySpaces.Interfaces" allowLocation="true" allowDefinition="Everywhere" restartOnExternalChanges="true"/>
        </sectionGroup>
      </configSections>
    
      <EntitySpaces>
        <connectionInfo default="Access">
          <connections>
            <add name="Access" providerMetadataKey="esDefault" sqlAccessType="DynamicSQL" provider="EntitySpaces.MSAccessProvider" providerClass="DataProvider" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\SharpDevelop Projects\EntitySpaces Output\Database\Northwind.mdb"/>
          </connections>
        </connectionInfo>
      </EntitySpaces>
    
    </configuration>
    

    My simple test code:

    Code:
    Module Program
    	Sub Main()
    		Entityspaces.Interfaces.esProviderFactory.Factory = New EntitySpaces.Loader.esDataProviderFactory()
    
    		Dim e As New BusinessObjects.Employees
    		e.LoadByPrimaryKey(1)
    		e.FirstName = e.FirstName + " - altered"
    		e.save
    	End Sub
    End Module
    

     

    All works fine - hope it gives you enough of a pointer

    Cheers

    Martin

  •  08-01-2008, 5:44 AM 10495 in reply to 10489

    Re: Newbie question

    Hi Martin,

    Thanks for reply. I've got rid of the Configuration message (old references).

    Finally solved it - SqlClientProvider (in app.config) was spelt SQLClientProvider.

    Thanks very much for your help.

    Don't you just love case sensitivity?

    Regards,

    Jules

  •  08-01-2008, 6:04 AM 10497 in reply to 10495

    Re: Newbie question

    Also, is it possible to change the default stored procedure prefix (usp_ rather than proc_)? Any ideas?

    Yes, run the "Settings" template and change the "Prefix" there. You will then need to regenerate your stored procedures and classes of course.


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  08-01-2008, 7:46 AM 10499 in reply to 10497

    Re: Newbie question

    Hi Mike,

     Thanks for the tip.

     ES2008 has saved me soooo much time.

    Think I'm gonna have to get me a copy... (legally, of course Smile

    Regards

    Jules

View as RSS news feed in XML