adapter.Fill(ds)在visual studio中是不可接受的

时间:2015-10-02 17:59:55

标签: vb.net dataset

我编写了以下代码来创建DataSet:

        <div class="table-responsive">
            <table class="table table-striped table-hover">
                <thead>
                    <tr>
                        <th class="col-xs-2">
                            <span></span>
                        </th>
                        <th class="col-xs-8" ng-click="sort('firstName')">
                            <span class="glyphicon sort-icon" ng-show="sortKey=='firstName'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
                        </th>
                        <th class="col-xs-2">
                            <span></span>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-click="showModal($event, user.emailAddress)" changeImage="{imageId: {{$index}}, colour: blue" dir-paginate="user in users|orderBy:sortKey:reverse|filter:search|itemsPerPage:5">
                        <td>
                            <!--img class="round" src="/images/profile-placeholder.jpg" width="50" height="50">
                                </img> -->
                                <img class="round" src={{user.profileImageUrl}} width="50" height="50"></img>
                        </td>
                        <!-- <td><img src={ {user.profileImageUrl}} width="100" height="100"></img></td> -->
                        <td>
                            <div style="padding-top:1em"><span>{{user.firstName}}</span>
                                <br>{{user.lastName}}
                                <br>{{user.profession}}</div>
                        </td>
                        <td>
                            <div style="padding-top:1em">
                                <img id={{$index}} src="images/arrow-right-pink.png" width="50" height="50"></div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>

在此,VS2015中的最后一行adp.Fill(ds)突出显示为错误:

  

重载解析失败,因为无法使用这些参数调用可访问的“填充”

我做错了什么???

我还导入了以下内容:

    Dim connectionString As String = "********"
    Dim conn As New SqlConnection(connectionString)
    conn.Open()

    Try
        Dim cmd As SqlCommand = conn.CreateCommand
        cmd.CommandText = "SELECT * FROM TABCODE WHERE TABCODE_FUNNUM='AAAREN02'"
        Dim adp As SqlDataAdapter = New SqlDataAdapter(cmd)
        Dim ds As DataSet = New DataSet

        adp.Fill(ds)

    Catch ex As Exception

    End Try

2 个答案:

答案 0 :(得分:0)

编辑:原本以为我发现了语法错误。已更改为Fill

使用不同的重载
Dim ds As DataSet = New DataSet()
adp.Fill(ds, "TabCodes")

答案 1 :(得分:-1)

试试这个。

Using connection As New SqlConnection(connectionString)
    Dim adp As New SqlDataAdapter()
    Dim dSet as Dataset = New DataSet()
    adp.SelectCommand = New SqlCommand(queryString, connection)
    adp.Fill(dSet)
End Using