vb.net - Fill datagridviews from stored querys on arrays -
i hope can me. accurate can. code:
dim productoarray = new list(of products)() ' <-- global ' --button method--- dim db2 new coneccionanexteldatacontext dim [produ] product = db2.products.singleordefault(function(x) x.product_id = integer.parse(idproduct.text.trim())) if [produ] isnot nothing productoarray.add([produ]) showbill.datasource = vbnull showbill.datasource = productoarray showtotalbill.text = productoarray.sum(function(x) x.price).tostring() else messagebox.show("product id doesn't exits") end if
im trying bill datagridview
content. i'm doing declare array products(linq datacontext)
type, after declaring array i'm using "filter" add products datagridview
, 1 one using product_id, when execute , press corresponding button gives me following error:
"specified cast not valid." on line
dim [produ] producto = db2.products.singleordefault(function(x) x.product_id = integer.parse(idproduct.text.trim()))
exception code:
system.invalidcastexception unhandled message=la conversión especificada no es válida. source=system.data.linq stacktrace: en system.data.linq.sqlclient.sqlprovider.execute(expression query, queryinfo queryinfo, iobjectreaderfactory factory, object[] parentargs, object[] userargs, icompiledsubquery[] subqueries, object lastresult) en system.data.linq.sqlclient.sqlprovider.executeall(expression query, queryinfo[] queryinfos, iobjectreaderfactory factory, object[] userarguments, icompiledsubquery[] subqueries) en system.data.linq.sqlclient.sqlprovider.system.data.linq.provider.iprovider.execute(expression query) en system.data.linq.table`1.system.linq.iqueryprovider.execute[tresult](expression expression) en system.linq.queryable.singleordefault[tsource](iqueryable`1 source, expression`1 predicate) en nextel_alpha.form1.lagrearventa_click(object sender, eventargs e) en c:\users\be\desktop\preview\nextel alpha\nextel alpha\form1.vb:línea 2044 en system.windows.forms.control.onclick(eventargs e) en system.windows.forms.control.wmmouseup(message& m, mousebuttons button, int32 clicks) en system.windows.forms.control.wndproc(message& m) en system.windows.forms.label.wndproc(message& m) en system.windows.forms.control.controlnativewindow.onmessage(message& m) en system.windows.forms.control.controlnativewindow.wndproc(message& m) en system.windows.forms.nativewindow.debuggablecallback(intptr hwnd, int32 msg, intptr wparam, intptr lparam) en system.windows.forms.unsafenativemethods.dispatchmessagew(msg& msg) en system.windows.forms.application.componentmanager.system.windows.forms.unsafenativemethods.imsocomponentmanager.fpushmessageloop(int32 dwcomponentid, int32 reason, int32 pvloopdata) en system.windows.forms.application.threadcontext.runmessageloopinner(int32 reason, applicationcontext context) en system.windows.forms.application.threadcontext.runmessageloop(int32 reason, applicationcontext context) en system.windows.forms.application.run(applicationcontext context) en microsoft.visualbasic.applicationservices.windowsformsapplicationbase.onrun() en microsoft.visualbasic.applicationservices.windowsformsapplicationbase.doapplicationmodel() en microsoft.visualbasic.applicationservices.windowsformsapplicationbase.run(string[] commandline) en nextel_alpha.my.myapplication.main(string[] args) en 17d14f5c-a337-4978-8281-53493378c1071.vb:línea 81 en system.appdomain._nexecuteassembly(assembly assembly, string[] args) en system.appdomain.executeassembly(string assemblyfile, evidence assemblysecurity, string[] args) en microsoft.visualstudio.hostingprocess.hostproc.runusersassembly() en system.threading.threadhelper.threadstart_context(object state) en system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state) en system.threading.threadhelper.threadstart() innerexception:
this isn't code problem
¡¡¡¡¡edit!!!!
i've discovered problem caused because bd in table of products have money type columns... anyway problem still here because don't know why happening u,u have tried other tables such clients has id int, name string , phone string , there's no problem.
Comments
Post a Comment