Hello,
There is a problem. Its filter only the last record.
Why I could not filter any data I want into a column from my textbox.
For example, if my column "A" I have:
Xhiami
Steve
Sami
When I insert into my textbox the value Steve Its doesn’t transfert this record. But when I write the last word for example Sami. Its shows. Only showing the last value.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data;
- using System.Data.SqlClient;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- SqlConnection conn = new SqlConnection("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename=C:\\Copy_table_to_table\\WindowsFormsApplication1\\test.mdf;Integrated Security = True;Integrated Security = True");
- SqlCommand comm;
- SqlDataAdapter da;
- string connstr = @"Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename=C:\\Copy_table_to_table\\WindowsFormsApplication1\\test.mdf;Integrated Security = True;Integrated Security = True";
- private void button1_Click(object sender, EventArgs e)
- {
- string myConnectionString;
- myConnectionString = "Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename = C:\\Copy_table_to_table\\WindowsFormsApplication1\\test.mdf; Integrated Security = True; Integrated Security = True";
- {
- conn = new SqlConnection("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename = C:\\Copy_table_to_table\\WindowsFormsApplication1\\test.mdf; Integrated Security = True; Integrated Security = True");
- if (conn.State != ConnectionState.Open)
- conn.Open();
- using (var cmd = new SqlCommand())
- {
- cmd.Connection = conn;
- cmd.CommandType = System.Data.CommandType.Text;
- cmd.CommandText = @"INSERT INTO test2 (DATA, A, B, C) SELECT DATA, A, B, C FROM test1 where A ='" + textBox1.Text + "'"; cmd.ExecuteNonQuery();
- }
- }
- Console.WriteLine("Done.");
- conn.Close();
- }
- }
- }