RE: datacolumn ; datatable in Visual Studio 2005 Beta 2
- From: GSchaefer <GSchaefer@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 16 Nov 2005 01:08:02 -0800
I really do not know why but if you will spend a little more spaces it will
work
..Expression = "IIf(price > 0 , price * tax , tax)"
"GSchaefer" wrote:
> Of Course I know there is a mistake. The expression must be
> .Expression = "IIf (price > 0, price * tax, 0)"
>
> but it is still the same result.
>
> GScaefer
>
> "GSchaefer" wrote:
>
> > The program failes at the 'IIF' expression. The whole code is working
> > properly with Visual Studio 2003. Does anybody know a patch or a work around.
> >
> > Thanks
> > Gerhrad
> >
> >
> > Dim table As DataTable = New DataTable("MyTable")
> >
> > ' Create the first column.
> > Dim priceColumn As DataColumn = New DataColumn
> > With priceColumn
> > .DataType = System.Type.GetType("System.Decimal")
> > .ColumnName = "price"
> > .DefaultValue = 50
> > End With
> >
> > ' Create the second, calculated, column.
> > Dim taxColumn As DataColumn = New DataColumn
> > With taxColumn
> > .DataType = System.Type.GetType("System.Decimal")
> > .ColumnName = "tax"
> > .Expression = "price * 0,0862"
> > End With
> >
> > ' Create third column
> > Dim totalColumn As DataColumn = New DataColumn
> > With totalColumn
> > .DataType = System.Type.GetType("System.Decimal")
> > .ColumnName = "total"
> > .Expression = "IIF price > 0, price * tax, 0)"
> > End With
> >
> >
> >
> >
> > System.Data.SyntaxErrorException was unhandled
> > Message="Syntax error: Missing operand after 'price' operator."
> > Source="System.Data"
> > StackTrace:
> > at System.Data.ExpressionParser.Parse()
> >
> > at System.Data.DataExpression..ctor(DataTable table, String
> > expression, Type type)
> >
> > at System.Data.DataColumn.set_Expression(String value)
> >
> > at TestExpressionSQL2005.Form1.CalcColumns() in D:\ProgEnt\Visual
> > Studio\projects\vb\TestExpressionSQL2005\TestExpressionSQL2005\Form1.vb:line
> > 31
> >
> > at TestExpressionSQL2005.Form1.Button1_Click(Object sender, EventArgs
> > e) in D:\ProgEnt\Visual
> > Studio\projects\vb\TestExpressionSQL2005\TestExpressionSQL2005\Form1.vb:line
> > 49
> >
> > 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 TestExpressionSQL2005.My.MyApplication.Main(String[] Args) in
> > 17d14f5c-a337-4978-8281-53493378c1071.vb:line 76
> >
> > 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()
> >
.
- References:
- datacolumn ; datatable in Visual Studio 2005 Beta 2
- From: GSchaefer
- RE: datacolumn ; datatable in Visual Studio 2005 Beta 2
- From: GSchaefer
- datacolumn ; datatable in Visual Studio 2005 Beta 2
- Prev by Date: Using a Recordset as a Data Source for a New Query and Resulting Recordset
- Next by Date: Differing Results between Record binding and Collect method
- Previous by thread: RE: datacolumn ; datatable in Visual Studio 2005 Beta 2
- Next by thread: How to sort Scandinavian letters using recordsets
- Index(es):