Compiler Error Message: BC30519:

SAD

Member
Joined
Aug 29, 2007
Messages
15
Programming Experience
Beginner
Hi

I am trying to display some data in a table but am getting the following error, but cannot see what to change to rectify this;

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30519: Overload resolution failed because no accessible 'New' can be called without a narrowing conversion:

Source Error:



Line 41: conn.Open()
Line 42:
Line 43: Dim da As New Odbc.OdbcDataAdapter(sql, conn)
Line 44: da.Fill(ds, "OutOfSpec")
Line 45: Return ds


My code for this is:
VB.NET:
    Function TotalOutOfSpec() As DataSet

        Dim conn = New Odbc.OdbcConnection

        Dim sql As String

        Dim ds As New DataSet

        Dim dtResults As New DataTable("OutOfSpec")

        sql = "SELECT SubjectID, TestID FROM TestResults WHERE OutofSpec = 'True'"


        ' connectionstring using session variable ConnString to connect to user's database
        conn.ConnectionString = Session.Item("ConnString")

        Conn.Open
     
        Dim da As New Odbc.OdbcDataAdapter(sql, conn)
        da.Fill(ds, "OutofSpec")
        Return ds

    End Function

Any ideas what I have done wrong?

Help greatly appreciated!

Thanks in advance :D
 
See revised code below and tell me if it works if you are not sure about the revisions I have made then please feel free to ask.

VB.NET:
Function TotalOutOfSpec() As DataSet

        Dim conn = New Odbc.OdbcConnection

        Dim sql As String

        Dim ds As New DataSet

        Dim dtResults As New DataTable("OutOfSpec")

        ds.tables.add(dtResults)

        sql = "SELECT SubjectID, TestID FROM TestResults WHERE OutofSpec = 'True'"


        ' connectionstring using session variable ConnString to connect to user's database
        conn.ConnectionString = Session.Item("ConnString")

        Dim da As New Odbc.OdbcDataAdapter(sql, conn)

         Try

        da.Fill(ds.tables(0))

       Catch Ex as Exception

       'Error Logging.....

       Return Nothing

       End Try





        Return ds

    End Function
 
See revised code below and tell me if it works if you are not sure about the revisions I have made then please feel free to ask.

VB.NET:
Function TotalOutOfSpec() As DataSet

        Dim conn = New Odbc.OdbcConnection

        Dim sql As String

        Dim ds As New DataSet

        Dim dtResults As New DataTable("OutOfSpec")

        ds.tables.add(dtResults)

        sql = "SELECT SubjectID, TestID FROM TestResults WHERE OutofSpec = 'True'"


        ' connectionstring using session variable ConnString to connect to user's database
        conn.ConnectionString = Session.Item("ConnString")

        Dim da As New Odbc.OdbcDataAdapter(sql, conn)

         Try

        da.Fill(ds.tables(0))

       Catch Ex as Exception

       'Error Logging.....

       Return Nothing

       End Try





        Return ds

    End Function

Hi, Thanks very much for the reply. I have tried your code but still get an error...:confused:

error is:

Compiler Error Message: BC30519: Overload resolution failed because no accessible 'New' can be called without a narrowing conversion:

Source Error:



Line 35: conn.ConnectionString = Session.Item("ConnString")
Line 36:
Line 37: Dim da As New Odbc.OdbcDataAdapter(sql, conn)
Line 38:
Line 39: Try


Any ideas?

I am only importing into this page: Imports System.Data
That won't affect it will it?

Thanks
 
Aha ... i was also wondering why you add the table in the dataset object at all.
You can proceed only with the datatable. Change the function type to datatable and make it that return the datatable (previously filled from dataadapter).
 
No mental hard that won't help i'm afraid. SAD turn on 'Option Strict' the error message will most likely change. From the code you provided I can't see why the compiler would want a narrowing conversion. Very odd unless i'm overlooking something basic. As I said turn on option strict and see if the error message changes.

EDIT: Change this line...

VB.NET:
Dim conn = New Odbc.OdbcConnection


to

VB.NET:
Dim conn as new Odbc.OdbcConnection
 
Hi

Thanks very much, changing the line you mention has fixed it. My apologies should have noticed that!

However, prob just about to ask something even dumber as new to displaying data in web pages but....

code now runs but my webpage doesn't display anything..., what should I do to get this new datatable "OoutOfSpec" to show?

Previous to trying the code I have sent I was trying to use a datagrid or dataview but got lost as I am using a session variable to connect to the database.

Any help would be great, thanks again!
 
hmmm, don't know if I am getting somewhere or nowhere fast! So any advise would be great...

To try and display the results of my sql statemet from my dataset, I have added the following to the end of the code which Vis781 kindly helped with:


GridView1.DataSource = ds
GridView1.DataBind()

I have then dragged a GridView onto my page in Design view and made sure it is visible by looking at its properties, but still nothing is displayed.

I have tried various ways of trying to set the datasource so my program knows where the data is to populate my datagrid with the datatable but nothing happening so far.

Can anyone help at all?

Thanks.
 
I don't do a lot of web stuff so I may be not be the best person to advise from here but first thing I would do is make sure that your query is actually returning rows from that database. After that I probably wouldn't set the dataset as the datasource. But use the datatable instead.

VB.NET:
Gridview1.Datasource = ds.tables(0)
 
Back
Top