SQL-строку не согласиться со списком выбранного текста
<pre> Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Dim ConnectionString As String Dim binding As New BindingSource ConnectionString = ("Integrated Security = true;Initial catalog = " & ComboBox2.SelectedText.ToString & ";Data Source = " & ComboBox1.SelectedText & "; ") Dim SQL As String = "SELECT * FROM Table_1" Dim conn As SqlConnection = New SqlConnection(ConnectionString) ' open the connection 'Create a SqlDataAdapter object Dim adapter1 As SqlDataAdapter = New SqlDataAdapter(SQL, conn) ' Call DataAdapter's Fill method to fill data from the ' Data Adapter to the DataSet Dim ds As New DataSet 'ds.Tables.Add("Table_1") conn.Open() adapter1.Fill(ds, "Table_1") conn.Close() binding.DataSource = ds binding.DataMember = "Table_1" DataGridView1.DataSource = binding End Sub
приведенный выше код не работает ошибка :дополнительная информация: недопустимое имя объекта "Table_1". когда я набираю начальный каталог вот так
pre>Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Dim ConnectionString As String Dim binding As New BindingSource ConnectionString = ("Integrated Security = true;Initial catalog = logistiki;Data Source = " & ComboBox1.SelectedText & "; ") Dim SQL As String = "SELECT * FROM Table_1" Dim conn As SqlConnection = New SqlConnection(ConnectionString) ' open the connection 'Create a SqlDataAdapter object Dim adapter1 As SqlDataAdapter = New SqlDataAdapter(SQL, conn) ' Call DataAdapter's Fill method to fill data from the ' Data Adapter to the DataSet Dim ds As New DataSet 'ds.Tables.Add("Table_1") conn.Open() adapter1.Fill(ds, "Table_1") conn.Close() binding.DataSource = ds binding.DataMember = "Table_1" DataGridView1.DataSource = binding End Sub
он работает он принимает выделенный текст combobox1 но не combobox2
кто-нибудь поможет?
Что я уже пробовал:
добавлена переменная для выделенного текста combox2 в строку sql, но она тоже не работает