Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ilimax
Posting Yak Master
164 Posts |
Posted - 2005-03-24 : 09:10:57
|
| I am trying to pull data type "bit" from Sql server into boolean variable with executing datareader in visual basic. net. For some reason this does not work ... does anybody know why and how I can pull data from this table field?Dim mScreen As BooleanmScreen = CBool(myData.Item("POSManagers")) |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-03-24 : 09:15:36
|
| What does "it doesn't work" mean? What is the error you are getting?- Jeff |
 |
|
|
ilimax
Posting Yak Master
164 Posts |
Posted - 2005-03-24 : 09:58:07
|
quote: Originally posted by jsmith8858 What does "it doesn't work" mean? What is the error you are getting?- Jeff
This is error text:An unhandled exception of type 'System.IndexOutOfRangeException' occurred in nscashiers.dllAdditional information: POSManagersError come from DLL file where I am trying to pull data from sql server ... |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-03-24 : 10:00:31
|
| Did you name the column correctly? Are you sure it exists in your DataReader/DataTable? The error you are getting indicates that the column name could not be found, not that it can't be converted.- Jeff |
 |
|
|
ilimax
Posting Yak Master
164 Posts |
Posted - 2005-03-24 : 10:43:05
|
quote: Originally posted by jsmith8858 Did you name the column correctly? Are you sure it exists in your DataReader/DataTable? The error you are getting indicates that the column name could not be found, not that it can't be converted.- Jeff
I had query "Select * from table1 where ID = '"& cID &"';" and change to "Select bla1, bla2,POSManagers from table1 where ID = '"& cID &"';"Now I do not get any data ...process stop in execution of datareader and I have this error:An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in nscashiers.dllAdditional information: System error.First time I pulled data from table and just conversion failed...I do not know ... something is really crazy about this table ... |
 |
|
|
ilimax
Posting Yak Master
164 Posts |
Posted - 2005-03-24 : 11:24:36
|
| What else is crazy here ... I have problem with fields I added yesterday to table ...reader pull data from table when I have this query "Select * from Table1;" and conversion failed on the fields I mad yesterday.I tried to reorganize datatype and I changed those field from "bit" to "smallint"...I changed my variables type and I got same message An unhandled exception of type 'System.IndexOutOfRangeException' occurred in nscashiers.dllAdditional information: POSManagersI went step by step and I see program failed on conversion ....here...It's look like reader bring any crazy data from table ...why?mScreen = CInt(myData.Item("POSManagers")) |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-03-24 : 11:51:51
|
| that's why you shouldn't use SELECT *. You need to re-configure your datatable and go through the wizard again, especially if you created a strongly typed dataset.- Jeff |
 |
|
|
SqlStar
Posting Yak Master
121 Posts |
Posted - 2005-03-25 : 00:49:12
|
quote: Originally posted by ilimax Dim mScreen As BooleanmScreen = CBool(myData.Item("POSManagers"))
Before getting data from Datatable, you have to check whether the datatable has rows/not. If datatable doesn't have any rows, how can you get that column value. I hope the problem is related with blank datatable.:) While we stop to think, we often miss our opportunity :) |
 |
|
|
|
|
|