0

这是我的代码:

Imports System.Data
Imports System.Data.SqlClient



Public Class Form2
Private conn As New SqlConnection("Data Source=wal1sql1;Initial Catalog=ValueTracker;Integrated Security=True")
Private da As SqlDataAdapter("SELECT * FROM tbl ValueSources", cs) 
Private ds As DataSet


'Declaration
Public Property AllowDBNull As Boolean


Private Sub AddNullAllowedColumn()
    Dim column As DataColumn
    column = New DataColumn("ValueSourceID", _
        System.Type.GetType("System.Int32"))
    column.AllowDBNull = True

    ' Add the column to a new DataTable. 
    Dim table As DataTable
    table = New DataTable
    table.Columns.Add(column)
End Sub


Private Sub ValueSourcesBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles ValueSourcesBindingNavigatorSaveItem.Click
    Me.Validate()
    Me.TableAdapterManager.UpdateAll(Me.ValueTrackerDataSet)

    Me.ValueSourcesBindingSource.EndEdit()


End Sub

我得到了错误Private da As SqlDataAdapter("SELECT * FROM tbl ValueSources", cs)

4

1 回答 1

1

你在你的行中失踪New。当您编写Private da As SqlDataAdapter("SELECT * FROM tbl ValueSources", cs)它时,它认为您提供的参数是类型声明的一部分。改用这个,

Private da As New SqlDataAdapter("SELECT * FROM tbl ValueSources", cs)

这将调用构造函数并应该修复您的错误。

于 2013-07-10T16:04:52.520 回答