Click here to Skip to main content

Visual Basic

 
QuestionQuery dataTable with .Compute Pinmembermebjen30-Jan-13 10:05 
AnswerRe: Query dataTable with .Compute PinmvpDave Kreskowiak30-Jan-13 11:20 
GeneralRe: Query dataTable with .Compute Pinmembermebjen30-Jan-13 11:45 
GeneralRe: Query dataTable with .Compute PinmvpDave Kreskowiak30-Jan-13 15:28 
You don't need to specify System. The System namespace is automatically imported in VB.NET. You also don't need to specify System.Type.GetType... GetType alone is sufficient.
    Dim col_invDate As DataColumn = New DataColumn("invDate")
    col_invDate.DataType = System.Type.GetType("System.DateTime")
    salesTable.Columns.Add(col_invDate)
should become this:
    Dim col_invDate As DataColumn = New DataColumn("invDate")
    col_invDate.DataType = GetType(DateTime)
    salesTable.Columns.Add(col_invDate)
 
Next, according to the documentation on DataTable.Compute and DataColumn.Expression, a DateTime value should be enclosed in single quotes or the # sign, depending on the underlying data provider.
 
...and to make things MUCH easier to read, don't use string concatentation:
x0 = yrSales.Compute("SUM(extPrice)", String.Format("shipToName = '{0}' AND invDate > #{1}# AND invDate < #{2}#", stn, begDate, endDate))
 
BTW: x0 is a terrible variable name. By looking at the variable name alone, what does it contain?? There is no way to tell.

QuestionWindows admin mode mistries Pinmembersolankinkdpr30-Jan-13 2:11 
AnswerRe: Windows admin mode mistries PinmvpEddy Vluggen30-Jan-13 8:51 
GeneralRe: Windows admin mode mistries Pinmembersolankinkdpr30-Jan-13 20:07 
AnswerRe: Windows admin mode mistries PinmvpEddy Vluggen30-Jan-13 23:35 
GeneralRe: Windows admin mode mistries Pinmembersolankinkdpr31-Jan-13 3:29 
GeneralRe: Windows admin mode mistries PinmvpEddy Vluggen31-Jan-13 4:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.150123.1 | Last Updated 26 Jan 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid