由于某种原因,我不断收到错误:数组边界不能出现在类型说明符中,我不知道这意味着什么

时间:2013-07-10 16:00:06

标签: vb.net

这是我的代码:

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)

收到错误

1 个答案:

答案 0 :(得分:1)

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

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

这将调用构造函数并修复错误。