TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Israel
690
1.3k
219.6k
Its ONLY displaying the last value. Not any values i need...
Dec 31 2019 7:51 AM
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();
//On this line
}
}
Console.WriteLine(
"Done."
);
conn.Close();
}
}
}
Reply
Answers (
1
)
need to performance tune by datareader
SQL Connection Error