Solved

Conversion problem

Posted on 2006-06-21
3
192 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 500 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

Industry Leaders: 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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

728 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