?
Solved

Conversion problem

Posted on 2006-06-21
3
Medium Priority
?
198 Views
Last Modified: 2010-08-05
Public Sub GetPathway(ByVal vABR_ID$)
        If SqlConnection1.State = ConnectionState.Closed Then
            SqlConnection1.Open()
        End If
        Dim DsPathway1 As String
        SqlDiplomateAdapter.SelectCommand.Parameters("@abr_id").Value = vABR_ID
        SqlDiplomateAdapter.Fill(DsPathway1)

The above code is an attempt to populate th a dataset.

However, the dataset includes to fields one is nvarchar and the other is a bit.  I'm getting an error say that  "As Interger  Value of type "string cannot be converted to System.Data.DataSet"
and
"As Interger  Value of type "string cannot be converted to System.Data.Datatable"

can I assume that that's because of the BIT?  What options do I have?

Regards
0
Comment
Question by:TimSweet220
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Expert Comment

by:fruhj
ID: 16955803
Dim DsPathway1 as string...

Did you mean to dim this as a dataset?
0
 

Author Comment

by:TimSweet220
ID: 16955837
DsPathway1 is a dataset already created from a DataAdapter
0
 
LVL 34

Accepted Solution

by:
Sancler earned 2000 total points
ID: 16956052
The first error probably relates, with its reference to DataSet, to this line

        Dim DsPathway1 As String

As you say, "DsPathway1 is a dataset ...".  You therefore cannot Dim it here As String (or if you do, you will have problems).

The second error probably relates, with its reference to DataTable, to this line

        SqlDiplomateAdapter.Fill(DsPathway1)

DataAdapters fill DataTables, not DataSets.  True, you can call .Fill(dataset) but that will just create a new table within the dataset that it can fill.  I anticipate - from what you say about the dataset being "... already created from a DataAdapter" - that you selected the "Generate Dataset ..." option when you were configuring the dataadapter and, if that is the case, there will be a specific datatable within the dataset that you probably need to specify in the call to the .Fill method.  So I think that line should probably be something like

        SqlDiplomateAdapter.Fill(DsPathway1, "MyTableName")

A couple of other points.  One is that, with dataadapters, you don't need explicitly to open their connections: they handle that automatically.  So these lines

        If SqlConnection1.State = ConnectionState.Closed Then
            SqlConnection1.Open()
        End If

are unnecessary.

And (although perhaps it doesn't matter in practice, I'm not sure) the argument that you pass to your sub is vABR_ID$, but the Value that you give to your parameter is vABR_ID.

What I think your sub ought to look like is this

Public Sub GetPathway(ByVal vABR_ID$)
        SqlDiplomateAdapter.SelectCommand.Parameters("@abr_id").Value = vABR_ID$
        SqlDiplomateAdapter.Fill(DsPathway1, "MyTableName") '<<< you put the right value in here

The Bit field shouldn't cause a problem but, even if it does, I don't thnk you've reached that problem yet ;-)

Roger
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question