Hi,
Thanks for replied.
I have recreated my project to test on my application.
Here the screen shot for issue:

References version Screen shot:



Software Info:
GP Dynamics 2013
Windows 7
Visual Studio 2010
My codes:
GPUser Class
Public Class GPUser
Public ReadOnly Property DataBase As String
Get
Return Dynamics.Globals.IntercompanyId.Value
End Get
End Property
Public ReadOnly Property UserID As String
Get
Return Dynamics.Globals.IntercompanyId.Value
End Get
End Property
Public ReadOnly Property Password As String
Get
Return Dynamics.Globals.SqlPassword.Value
End Get
End Property
Public ReadOnly Property DataSource As String
Get
Return Dynamics.Globals.SqlDataSourceName.Value
End Get
End Property
Public ReadOnly Property ConnectionString As SqlClient.SqlConnectionStringBuilder
Get
Return New SqlClient.SqlConnectionStringBuilder With {.DataSource = DataSource, .UserID = UserID, .Password = Password, .ApplicationName = "GP", .InitialCatalog = DataBase}
End Get
End Property
Public ReadOnly Property CompanyId As Short
Get
Return Dynamics.Globals.CompanyId.Value
End Get
End Property
Public ReadOnly Property UserDate As DateTime
Get
Return Dynamics.Globals.UserDate.Value
End Get
End Property
End Class
My Form Codes:
Private Sub SimpleButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton1.Click
Dim myTestClass As New GPUser
MsgBox(myTestClass.ConnectionString) <-- This line triggered error
Dim cn As New System.Data.SqlClient.SqlConnection()
Dim cmd As New System.Data.SqlClient.SqlCommand()
Dim rst As System.Data.SqlClient.SqlDataReader
Dim resp As Int32
Microsoft.Dexterity.GPConnection.Startup()
' Create the connection object
Dim GPConnObj As New Microsoft.Dexterity.GPConnection()
' Initialize
resp = GPConnObj.Init("<Key1>", "<Key2>")
' Make the connection
cn.ConnectionString = "DATABASE=TWO"
GPConnObj.Connect(cn, "GP", "LESSONUSER1", "access")
' Check the return code
If ((GPConnObj.ReturnCode And
CType(Microsoft.Dexterity.GPConnection.ReturnCodeFlags.SuccessfulLogin, Integer)) = CType(Microsoft.Dexterity.GPConnection.ReturnCodeFlags.SuccessfulLogin, Integer)) Then
' Specify the command retrieve all customers
cmd.Connection = cn
cmd.CommandText = "Select * From RM00101"
' Execute the command
rst = cmd.ExecuteReader()
rst.Read()
' Display the name of the first customer
MessageBox.Show((rst.GetValue(1).ToString()))
' Close the connection
cn.Close()
Else
MessageBox.Show("Login failed")
End If
' Dispose of the connection object
GPConnObj = Nothing
'Shut down the object
Microsoft.Dexterity.GPConnection.Shutdown()
End Sub
Hope can hear from you again soonest. :)
Regards,
Jim