Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Conversion problem

Posted on 2006-06-21
3
Medium Priority
?
202 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

636 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