ник: Едрёныч
cmd.Parameters.AddWithValue(@CustomerID,Me.Combobox1.SelectedItem) пишет, что требуется выражение для @CustomerID
я ещё так делал:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim strConn4 As New SqlConnectionStringBuilder()
strConn4.DataSource = ".\SQLExpress"
strConn4.InitialCatalog = "Northwind"
strConn4.IntegratedSecurity = True
Using cn4 As New SqlConnection(strConn4.ConnectionString)
cn4.Open()
Dim CustomerID As SqlParameter
CustomerID = New SqlClient.SqlParameter("@CustomerID", SqlDbType.NChar)
CustomerID.Value = ComboBox1.SelectedValue
Dim cmd As New SqlCommand("sp_ContactName", cn4)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@CustomerID", SqlDbType.NChar)
cmd.Parameters("@CustomerID") = CustomerID
cmd.Parameters.AddWithValue("@CustomerID", Me.ComboBox1.SelectedValue)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
da.Fill(ds, "Customers")
DataGridView1.DataBindings.Add("", (ds), "CustomerID")
DataGridView1.DataMember = "Customers"
DataGridView1.DataSource = ds
cn4.Close()
End Using
End Sub
ошибка появляется около da.Fill(ds, "Customers")