这是我的代码:
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)
答案 0 :(得分:1)
您遗失的New
行。当你写Private da As SqlDataAdapter("SELECT * FROM tbl ValueSources", cs)
时,它认为你提供的参数是类型声明的一部分。
改为使用它,
Private da As New SqlDataAdapter("SELECT * FROM tbl ValueSources", cs)
这将调用构造函数并修复错误。