Solved

Conversion problem

Posted on 2006-06-21
3
178 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
3 Comments
 
LVL 12

Expert Comment

by:fruhj
Comment Utility
Dim DsPathway1 as string...

Did you mean to dim this as a dataset?
0
 

Author Comment

by:TimSweet220
Comment Utility
DsPathway1 is a dataset already created from a DataAdapter
0
 
LVL 34

Accepted Solution

by:
Sancler earned 500 total points
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now