convert Date column to string / label if NOT IsDBNull - vb.net

I am trying (much too long) to convert a DateTime column to a label.Text.
Various errors:
What am I missing?
drExpDatesRow = dtAllCompanies.Select("CompanyID = " + CompanyID.ToString())
Dim ls_ExpiresDateString As String
If (Not IsDBNull(drExpDatesRow("Expdate"))) Then
Date.TryParse(drExpDatesRow("Expdate").ToString(), ls_ExpiresDateString)
'ls_ExpiresDateString = ldt_ExpiresDate.ToString("MM/dd/yyyy")
lbl_ExpireDate.Text = ls_ExpiresDateString.ToString()
Else
lbl_ExpireDate.Text = ""
End If
System.InvalidCastException was unhandled Message=Conversion from
string "Expdate" to type 'Integer' is not valid.
Source=Microsoft.VisualBasic StackTrace:
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String
Value)
at zzz.winCompanyInfo.CompanyInfo_Load(Object sender, EventArgs e) in C:\inetpub\zzz.vb:line 638
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(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) InnerException:
System.FormatException
Message=Input string was not in a correct format.
Source=Microsoft.VisualBasic
StackTrace:
at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String
Value, NumberFormatInfo NumberFormat)
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String
Value)
InnerException:
UPDATE** Added DataRow logic

When using TryParse use the same data type.
Dim drExpDatesRow = (From dr As DataRow In dtAllCompanies.Rows
Where dr("CompanyId").ToString =
CompanyID.ToString).FirstOrDefault
Dim ls_ExpiresDate As Date ' Date not String
If (Not drExpDatesRow Is Nothing) Then
If Date.TryParse(drExpDatesRow("Expdate").ToString(), ls_ExpiresDate)
lbl_ExpireDate.Text = ls_ExpiresDate.ToString()
End If
Else
lbl_ExpireDate.Text = ""
End If

You had multiple issues in your code. This one should take care of things for good
drExpDatesRow = dtAllCompanies.Select("CompanyID = " + CompanyID.ToString()) ' returns array
lbl_ExpireDate.Text = ""
If drExpDatesRow.Length > 0 Then
If (Not IsDBNull(drExpDatesRow(0)("Expdate"))) Then
Dim myDate As DateTime
Dim res As Boolean = Date.TryParse(drExpDatesRow("Expdate"), myDate)
If res Then lbl_ExpireDate.Text = MyDate.ToString("<format>")
End If
End If

Related

arabic text printing using raw printing in c#

I need to print arabic text using raw printing am using below code. But its printing ????? instated of text
Public Function SendStringToPrinter(szPrinterName As String, szString As String) As Boolean
If PrinterOpen Then
Dim pBytes As IntPtr
Dim dwCount As Int32
Dim dwWritten As Int32 = 0
dwCount = szString.Length
pBytes = Marshal.StringToCoTaskMemAnsi(szString)
SendStringToPrinter = WritePrinter(hPrinter, pBytes, dwCount, dwWritten)
Marshal.FreeCoTaskMem(pBytes)
Else
SendStringToPrinter = False
End If
End Function

Replace a text with all alphabet VB.NET

I just stopped by this error
System.NullReferenceException was unhandled HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=System.Windows.Forms StackTrace:
at System.Windows.Forms.RichTextBox.StreamIn(String str, Int32 flags)
at System.Windows.Forms.RichTextBox.set_SelectedText(String value)
at Novania_JAV_Viewer_EncDec.Form1.Button1_Click(Object sender, EventArgs ef) in c:\users\toshiba\documents\visual studio
2010\Projects\Novania JAV Viewer EncDec\Novania JAV Viewer
EncDec\Form1.vb:line 91
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(IntPtr
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 Novania_JAV_Viewer_EncDec.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart() InnerException:
and this is my whole code, I am trying to replace all alphabet in one word, and it needs to replace one by one, and one by one variable.
the error is located here ("title") word
Do Until RichTextBox1.Find("titelz") = -1
RichTextBox1.Find("titelz")
RichTextBox1.SelectedText = titel
and this is my whole form class code
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
RichTextBox1.LoadFile("template.rtf")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal ef As System.EventArgs) Handles Button1.Click
Dim A As String
Replace(TextBox1.Text, "A", "5TY5")
Console.WriteLine(A)
Dim B As String
Replace(A, "B", "WEE")
Console.WriteLine(B)
Dim C As String
Replace(B, "C", "23RW")
Console.WriteLine(C)
Dim D As String
Replace(C, "D", "RW4R")
Console.WriteLine(D)
Dim E As String
Replace(D, "E", "DFS")
Console.WriteLine(E)
Dim F As String
Replace(E, "F", "R5")
Console.WriteLine(F)
Dim G As String
Replace(F, "G", "QWEDQ")
Console.WriteLine(G)
Dim H As String
Replace(G, "H", "ZDCZ")
Console.WriteLine(H)
Dim I As String
Replace(H, "I", "VGHN")
Console.WriteLine(I)
Dim J As String
Replace(I, "J", "ZSC")
Console.WriteLine(J)
Dim K As String
Replace(J, "K", "ZSD")
Console.WriteLine(K)
Dim L As String
Replace(K, "L", "WER")
Console.WriteLine(L)
Dim M As String
Replace(L, "M", "GN")
Console.WriteLine(M)
Dim N As String
Replace(M, "N", "xfv")
Console.WriteLine(N)
Dim O As String
Replace(N, "O", "DAASAD")
Console.WriteLine(O)
Dim P As String
Replace(O, "P", "WET")
Console.WriteLine(P)
Dim Q As String
Replace(P, "Q", "DFCV")
Console.WriteLine(Q)
Dim R As String
Replace(Q, "R", "ADSDA")
Console.WriteLine(R)
Dim S As String
Replace(R, "S", "SGFDG")
Console.WriteLine(S)
Dim T As String
Replace(S, "T", "SFSFD")
Console.WriteLine(T)
Dim U As String
Replace(T, "U", "AWDAD")
Console.WriteLine(U)
Dim V As String
Replace(U, "V", "RERE")
Console.WriteLine(V)
Dim W As String
Replace(V, "W", "GBGDBB")
Console.WriteLine(W)
Dim X As String
Replace(W, "X", " AWDAW ")
Console.WriteLine(X)
Dim Y As String
Replace(X, "Y", "AWDEAVA")
Console.WriteLine(Y)
Dim Z As String
Replace(Y, "Z", "AWEDWADW")
Console.WriteLine(Z)
Dim titel As String = Z
Do Until RichTextBox1.Find("titelz") = -1
RichTextBox1.Find("titelz")
RichTextBox1.SelectedText = titel
Loop
RichTextBox2.Text = RichTextBox1.Text
RichTextBox1.Clear()
RichTextBox1.LoadFile("template.rtf")
End Sub
End Class
In order to do the replace, I'd try the following code...
It uses a Dictionary type variable. They are used in .NET quite a lot as some sort of associative array.
' First, create dictionary that you can loop through.
' This variable is created on form level (so only once)
' and contains all the "words" as key-value pairs.
' So you can search for key and replace with value.
Dim replaceDictionary As New Dictionary(Of String, String) From {{"A", "5TY5"}, _
{"B", "WEE"}, _
{"C", "23RW"}, _
{"D", "RW4R"}, _
{"E", "DFS"}, _
{"F", "R5"}, _
{"G", "QWEDQ"}, _
{"H", "ZDCZ"}, _
{"I", "VGHN"}, _
{"J", "ZSC"}, _
{"K", "ZSD"}, _
{"L", "WER"}, _
{"M", "GN"}, _
{"N", "xfv"}, _
{"O", "DAASAD"}, _
{"P", "WET"}, _
{"Q", "DFCV"}, _
{"R", "ADSDA"}, _
{"S", "SGFDG"}, _
{"T", "SFSFD"}, _
{"U", "AWDAD"}, _
{"V", "RERE"}, _
{"W", "GBGDBB"}, _
{"X", " AWDAW "}, _
{"Y", "AWDEAVA"}, _
{"Z", "AWEDWADW"}
}
Private Sub btnReplace_Click(sender As System.Object, e As System.EventArgs) Handles btnReplace.Click
' Declare temporary variable to store text
Dim tmpText As String = txtTitel.Text
' Loop through dictionary
For Each replaceItem In replaceDictionary
' Replace key ("A" etc.) with value ("5TY5" etc.)
' and store in temporary variable
tmpText = Replace(tmpText, replaceItem.Key, replaceItem.Value)
Next
'Display text
txtTitel.Text = tmpText
End Sub
Now for your "find" part... nothing like "titelz" is going to be changed with above code (only caps), so if it was in there, it stays in there.
So I have no idea what to do with that...
Edit
For the record: this goes for a long line of replaces... Once you've replaced all the A's in your string, the T from "5TY5" will also be replaced.
If you don't want this, you'll have to split the original text into characters and start checking them one by one.
Checking title string one letter at a time
There are a few changes to above code:
Dictionary is now of type (Char, String) instead of 2 strings.
The title is stored in a seperate variable in order to keep working with the orignal title text.
Instead of looping through the dictionary, you loop through the title text one letter at a time.
The code is documented with comments and should be pretty self-explanatory.
Good luck!
' First, create dictionary that you can loop through.
' This variable is created on form level (so only once)
' and contains all the "words" as key-value pairs.
' So you can search for key and replace with value.
Dim replaceDictionary As New Dictionary(Of Char, String) From {{"A", "5TY5"}, _
{"B", "WEE"}, _
{"C", "23RW"}, _
{"D", "RW4R"}, _
{"E", "DFS"}, _
{"F", "R5"}, _
{"G", "QWEDQ"}, _
{"H", "ZDCZ"}, _
{"I", "VGHN"}, _
{"J", "ZSC"}, _
{"K", "ZSD"}, _
{"L", "WER"}, _
{"M", "GN"}, _
{"N", "xfv"}, _
{"O", "DAASAD"}, _
{"P", "WET"}, _
{"Q", "DFCV"}, _
{"R", "ADSDA"}, _
{"S", "SGFDG"}, _
{"T", "SFSFD"}, _
{"U", "AWDAD"}, _
{"V", "RERE"}, _
{"W", "GBGDBB"}, _
{"X", " AWDAW "}, _
{"Y", "AWDEAVA"}, _
{"Z", "AWEDWADW"}
}
Private Sub btnReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReplace.Click
' Declare temporary variable to store text
Dim tmpTitle As String = txtTitel.Text
Dim tmpText As String = ""
Dim tmpLetter As Char
' Loop through title string
Dim i As Integer = 0
Do While (i < tmpTitle.Length)
' Increase counter
i += 1
' Save next letter in tmpLetter
tmpLetter = Mid(tmpTitle, i, 1)
' Check for key in dictionary
If replaceDictionary.ContainsKey(tmpLetter) Then
' When found, append associated value to tmpText
tmpText &= replaceDictionary(tmpLetter)
Else
' Not found: use letter from title string
tmpText &= CStr(tmpLetter)
End If
Loop
'Display text
txtTitel.Text = tmpText
End Sub

SAP Catching Data with RFC_CALL_TRANSACTION RFC VB

I become an errorcode 1001, an SAP Remote error?
I've googled alot but didn't find anything.
Maybe someone knows whats the Problem here.
Im using SAP 720.
System.Runtime.InteropServices.COMException (0x000003E9): SAP Remote
Function Call bei
Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o,
Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack) bei
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack) ...
Here is my code:
Public FunctionCtrl As Object
Function login_Call()
Try
Dim conn As Object
FunctionCtrl = CreateObject("SAP.Functions")
conn = FunctionCtrl.Connection
conn.System = XXX
conn.ApplicationServer = XXX
conn.SystemNumber = XXX
conn.Client = "XXX"
conn.user = XXX
conn.Password = XXX
conn.Language = XXX
'needed for frontend dialog
conn.RfcWithDialog = True
'log on with logon dialog
If Not conn.Logon(0, 1) Then
Dim WsShell
Dim intText As Integer
WsShell = CreateObject("WScript.Shell")
intText = WsShell.Popup("Logon not succesful." & vbCrLf & _
"will be closed automatically in one minute...", 60)
'conn = Nothing
Anmeldung_Call = False
Exit Function
End If
Anmeldung_Call = True
Catch ex As Exception
Anmeldung_Call = False
End Try
Me.Text = DateTime.Now.ToString()
End Function
Sub Open_IW73()
Dim BdcTable As Object
Dim RfcCallTransaction As Object
Dim Messages As Object
Dim count As Integer
'call transaction IW73
RfcCallTransaction = FunctionCtrl.Add("RFC_CALL_TRANSACTION")
RfcCallTransaction.Exports("TRANCODE") = "IW73"
RfcCallTransaction.Exports("UPDMODE") = "S"
BdcTable = RfcCallTransaction.Tables("BDCTABLE").....
The Error comes in this line: "RfcCallTransaction = FunctionCtrl.Add("RFC_CALL_TRANSACTION")
"
Thank you
I've had the same error. People suggested different fixes like using SAP.functions.Unicode.
What did it for me was simply changing to "RFC_CALL_TRANSACTION_USING". I'm not sure of the exact difference between these commands, so be careful with that. So far it has been working for me though.

Getting Error at insert on Visual Basic .Net

im trying to make an insert to my Database and im receiving an error, is my first time with VB.Net so any help would be greatly appreciated.
Here is the code:
Sub InsertGestion(ByVal s As Object, ByVal e As EventArgs)
Dim Records() As String
Records = Split(TBComment.Text, vbCrLf)
Dim record As Integer
For record = 0 To UBound(Records)
oracleCommand = New OracleCommand("INSERT INTO ACTFIL (ACACCTG,ACACCT,ACACTDTE,ACSEQNUM,ACACCODE,ACRCCODE,ACCIDNAM,ACCOMM) values ('1','" + TBNum.text + "','" + TBFecha.Text + "',"+ (record+1) +",'"+TBCodAc.text+"','"+TBCodRes.text+"','"+TBGestor.Text+"','"+record+"')", oracleConexion)
Try
oracleConexion.Open()
oracleCommand.ExecuteNonQuery()
Catch ex As Exception
status.Text = "ERROR al insertar la gestiĆ³n " + ex.Message + "'" '& ex.Message
Finally
oracleConexion.Close()
Response.Redirect("gestiones.aspx?credito=" + Request.QueryString("credito") + "")
End Try
Next
End Sub
And the Error:
FormatException: Input string was not in a correct format.]
Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) +717374
Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) +114
[InvalidCastException: Conversion from string "INSERT INTO ACTFIL (ACACCTG,ACAC" to type 'Double' is not valid.]
Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) +717687
ASP.marcador_gestiones_aspx.InsertGestion(Object s, EventArgs e) in G:\vta-paqV2\marcador\gestiones.aspx:62
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
This was originally an update and it was working, i just modified the OracleCommand.
Btw, i notice this is not a secure way to execute the queries, if someone can point me on the right direction i'd really appreciate it.
Extract the oracle command from the query and run on Oracle client. That will let you know if there is anything wrong with your oracle command.
Secondly you can use string.format to form your query rather using + operator.
Secure approach to deal with query inputs is through input parameters. You can check below links.
http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oracleparameter.aspx
http://blogs.msdn.com/b/alextch/archive/2007/08/21/using-data-parameters-with-oracle-data-provider-for-net.aspx
I hope this helps.
Thanks!
Dhananjay

LINQ compiled query won't execute - ArgumentNulException was unhandled

I'm testing the Compiled Queries for the first time.
My current query is:
Shared compiledLatestDate As Func(Of RackJobbingDataDataContext, ArtikelInfoParameters, List(Of VerdelingPlanning)) = _
CompiledQuery.Compile(Of RackJobbingDataDataContext, ArtikelInfoParameters, List(Of VerdelingPlanning))( _
Function(db As RackJobbingDataDataContext, param As ArtikelInfoParameters) _
(From verdplan As VerdelingPlanning In db.VerdelingPlannings _
Join artPlan As ArtikelPlanning In db.ArtikelPlannings _
On artPlan.VerdelingPlanningID Equals verdplan.VerdelingPlanningID _
Join levDet As LeveringDetail In db.LeveringDetails _
On levDet.ArtikelPlanningID Equals artPlan.ArtikelPlanningID _
Join lev As Levering In db.Leverings _
On lev.LeveringID Equals levDet.LeveringID _
Where artPlan.ArtikelID.Equals(param.artId) _
And lev.WinkelID.Equals(param.winkId) _
And Not levDet.PlanningAantal.Equals(Nothing) _
And levDet.PlanningAantal <> 0 _
And verdplan.Datum < param.datumVerdeling _
Order By verdplan.Datum Descending _
Select levDet))
But i receive an ArgumentNulException was unhandled.
It was advised for LINQ queries to add an object with the required parameters, so this is the class:
Public Class ArtikelInfoParameters
Private _wkId As Guid
Private _artId As Guid
Private _datumVerdeling As DateTime
Public Sub New(ByVal artId As Guid, ByVal winkId As Guid, ByVal datumVerdeling As DateTime)
_artId = artId
_wkId = winkId
_datumVerdeling = datumVerdeling
End Sub
Public Property artId As Guid
Get
Return _artId
End Get
Set(ByVal value As Guid)
_artId = value
End Set
End Property
Public Property winkId As Guid
Get
Return _wkId
End Get
Set(ByVal value As Guid)
_wkId = value
End Set
End Property
Public Property datumVerdeling As DateTime
Get
Return _datumVerdeling
End Get
Set(ByVal value As DateTime)
_datumVerdeling = value
End Set
End Property
End Class
And for the sake of being complete, this is the error i'm receiving.
bij System.Data.Linq.SqlClient.SqlJoin.set_Left(SqlSource value)
bij System.Data.Linq.SqlClient.SqlMultiplexer.Visitor.VisitMultiset(SqlSubSelect sms)
bij System.Data.Linq.SqlClient.SqlVisitor.VisitSubSelect(SqlSubSelect ss)
bij System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
bij System.Data.Linq.SqlClient.SqlVisitor.VisitExpression(SqlExpression exp)
bij System.Data.Linq.SqlClient.SqlMultiplexer.Visitor.VisitSelect(SqlSelect select)
bij System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
bij System.Data.Linq.SqlClient.SqlProvider.BuildQuery(ResultShape resultShape, Type resultType, SqlNode node, ReadOnlyCollection`1 parentParameters, SqlNodeAnnotations annotations)
bij System.Data.Linq.SqlClient.SqlProvider.BuildQuery(Expression query, SqlNodeAnnotations annotations)
bij System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Compile(Expression query)
bij System.Data.Linq.CompiledQuery.ExecuteQuery(DataContext context, Object[] args)
bij System.Data.Linq.CompiledQuery.Invoke[TArg0,TArg1,TResult](TArg0 arg0, TArg1 arg1)
bij RackJobbing.UI.ucArtikelInfo.getLatestDate(Guid artikelId) in D:\EasySolutions\TFS\Provoost\Development\RackJobbing\RackJobbing.UI\Snelinvoer\Verdeling\ucArtikelInfo.vb:regel 69
bij RackJobbing.UI.ucArtikelInfo.UpdateInfo() in D:\EasySolutions\TFS\Provoost\Development\RackJobbing\RackJobbing.UI\Snelinvoer\Verdeling\ucArtikelInfo.vb:regel 111
bij RackJobbing.UI.frmPrePlanning.UcVerdeling1_ArtikelWinkelChanged() in D:\EasySolutions\TFS\Provoost\Development\RackJobbing\RackJobbing.UI\Snelinvoer\Verdeling\frmPrePlanning.vb:regel 280
bij RackJobbing.UI.ucVerdeling.grdVerdeling_EnterCell(Object sender, EventArgs e) in D:\EasySolutions\TFS\Provoost\Development\RackJobbing\RackJobbing.UI\Snelinvoer\Verdeling\ucVerdeling.vb:regel 339
bij C1.Win.C1FlexGrid.C1FlexGridBase.OnEnterCell(EventArgs e)
bij C1.Win.C1FlexGrid.C1FlexGridBase.a9()
bij C1.Win.C1FlexGrid.C1FlexGridBase.OnGridChanged(Object sender, GridChangedEventArgs e)
bij C1.Win.C1FlexGrid.C1FlexGrid.OnGridChanged(Object sender, GridChangedEventArgs e)
bij C1.Win.C1FlexGrid.t.bc(GridChangedTypeEnum A_0, Int32 A_1, Int32 A_2, Int32 A_3, Int32 A_4)
bij C1.Win.C1FlexGrid.t.bn(GridChangedTypeEnum A_0)
bij C1.Win.C1FlexGrid.p.n(C1FlexGridBase A_0, CellRange A_1, Boolean A_2)
bij C1.Win.C1FlexGrid.C1FlexGridBase.Select(CellRange rg, Boolean show)
bij C1.Win.C1FlexGrid.ab.o(MouseEventArgs A_0)
bij C1.Win.C1FlexGrid.ab.l(MouseEventArgs A_0)
bij C1.Win.C1FlexGrid.C1FlexGridBase.OnMouseDown(MouseEventArgs e)
bij System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
bij System.Windows.Forms.Control.WndProc(Message& m)
bij C1.Win.C1FlexGrid.Util.BaseControls.ScrollableControl.WndProc(Message& m)
bij System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bij System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bij System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bij System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bij System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
bij System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bij System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bij System.Windows.Forms.Application.Run(ApplicationContext context)
bij Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
bij Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
bij Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
bij RackJobbing.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:regel 81
bij System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
bij System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bij Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bij System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bij System.Threading.ThreadHelper.ThreadStart()
I'd appreciate any help in solving my problem , because i really can't seem to find the solution :(
Unlike SQL, the ON clause's left and right sides have different scope visibility.
You need to put variables that were in scope before the JOIN on the left side of the ON clause, and variables that are newly in scope from the JOIN on the right side.
Here I have switched the variables in ON clauses.
From verdplan As VerdelingPlanning In db.VerdelingPlannings _
Join artPlan As ArtikelPlanning In db.ArtikelPlannings _
On verdplan.VerdelingPlanningID Equals artPlan.VerdelingPlanningID _
Join levDet As LeveringDetail In db.LeveringDetails _
On artPlan.ArtikelPlanningID Equals levDet.ArtikelPlanningID _
Join lev As Levering In db.Leverings _
On levDet.LeveringID Equals lev.LeveringID _
Solution:
Public Shared CompiledLatestDate As Func(Of RackJobbingDataDataContext, ArtikelInfoParameters, IQueryable(Of VerdelingPlanning)) = _
CompiledQuery.Compile(Function(db As RackJobbingDataDataContext, artInfo As ArtikelInfoParameters) _
From verdplan As VerdelingPlanning In db.VerdelingPlannings _
Join artPlan As ArtikelPlanning In db.ArtikelPlannings _
On verdplan.VerdelingPlanningID Equals artPlan.VerdelingPlanningID _
Join levDet As LeveringDetail In db.LeveringDetails _
On artPlan.ArtikelPlanningID Equals levDet.ArtikelPlanningID _
Join lev As Levering In db.Leverings _
On levDet.LeveringID Equals lev.LeveringID _
Where artPlan.ArtikelID.Equals(artInfo.artId) _
And lev.WinkelID.Equals(artInfo.winkId) _
And Not levDet.PlanningAantal.Equals(Nothing) _
And levDet.PlanningAantal <> 0 _
And verdplan.Datum < artInfo.datumVerdeling _
Order By verdplan.Datum Descending _
Select verdplan)
Solved almost all of my problems, even though i sometimes get a NullReferenceException when there is no value in the collection (it doesn't always give an error, so i'm still looking into that).