my computed column doesn't work when my fill command is activated

raokikun

Member
Joined
Aug 17, 2011
Messages
15
Programming Experience
Beginner
[windows forms]
when i experimented..

my computed column doesn't work when my fill command is activated

i mean the command to show the record of my table..

but when i take off the code for the fill command..

the computed column works..
 
First up, are you really using .NET 1.0? I doubt it. If not, please help us by updating your profile to accurately reflect the .NET version you primarily use. If you're using VB 2010 then it will be .NET 4.0 by default.

As for the question, we would need a fuller and clearer explanation of the problem. For a start, what exact does "doesn't work" mean? Is an exception thrown? If so, what type and what is the error message? If not, what does happen? What's the actual code you're executing, including VB and SQL code? Does this computed column exist in the database, the DataTable or both? Are you using a typed DataSet generated by the Data Source wizard, or did you create your own DataAdapter?
 
i added the database and table by using the "add new data source"
so i can edit the dataset in the dataset designer mode
for putting the expression IIF(Grade >=4, 'Failed', IIF(Grade IN (1,1.25,1.50,1.75,2,2.25,2.50,2.75,3), 'PASSED','UNKNOWN'))


the database and table is made from sql2005

but our professor dont let us using the drag and drop style or add new data source.
unless we combine it by using codes

and this is my code..

Imports System.Data.SqlClient


Public Class testing
Private cs As New SqlConnection("Data Source=JARM\SQLEXPRESS;Initial Catalog=StudentRecordsDatabase;Integrated Security=True")
Private da As New SqlDataAdapter("SELECT * FROM ccsSTUDENTS", cs)
Private ds As New DataSet
Private cmb As New SqlCommandBuilder(da)

Private Sub testing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

da.Fill(ds, "ccsSTUDENTS")
CcsSTUDENTSDataGridView.DataSource = ds.Tables("ccsSTUDENTS")


the problem is...
when i take off the code

da.Fill(ds, "ccsSTUDENTS")
CcsSTUDENTSDataGridView.DataSource = ds.Tables("ccsSTUDENTS")

the computed column works.
but the datagrid shows no values or records.

----
but when i put the code back

da.Fill(ds, "ccsSTUDENTS")
CcsSTUDENTSDataGridView.DataSource = ds.Tables("ccsSTUDENTS")




it shows the records and values.. but the computed column doesnt work..

i got on error on executing the programming.. no exceptions or warnings..

the computed column does not really works.


this is the last problem for my thesis.. how you can help me sir.. thank you and good day!
 
You say that you created a Data Source but then your code doesn't use it all, so the fact that you created one is irrelevant to this issue.
i got on error on executing the programming.. no exceptions or warnings..
If an "error" occurs when you run the app then that is an exception being thrown. I assume that you mean that there are no compilation errors, i.e. the project builds successfully. If there's a run time error then there's an error message, provided as a diagnostic aid. If you'd like us to diagnose the issue then we would need that info.

If I had to guess I'd say that it's a syntax error in the Expression, but I'm not sure. If that's the case, the way to deal with such things is to start simple and build up to what you need. Start with just one IIF statement and get that to work first. Once that's working, increase the complexity bit by bit until you end up with exactly what you need. If you get an error at some point then you know exactly where the error is because you know that everything that went before works as it should.
 
Back
Top