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
Tayyab Jatoi
NA
135
28k
I want to search the rows which matches given keyword.
Oct 8 2019 10:42 AM
I have a table where for one person i have several records.
I have combined several record for one person in one row with the following code and having total balance in this row.
Question
Now my challenge is i want to search the person by using keyword.Like if i give name it will display only that person row in the datagrid view??
*Form is attached with with post.
private
void
btnSaleSearch_Click(
object
sender, EventArgs e)
{
SqlConnection conn =
new
SqlConnection(myconnstrng);
//Create Datatable to hold the data frmo database
DataTable dt =
new
DataTable();
try
{
decimal
j = 0;
string
sql =
"select Name, SUM(Balance_Amt) As Balance_Amt from tbl_Transactions_Rak Group By Name"
;
SqlCommand cmd =
new
SqlCommand(sql, conn);
//Sql data Adapter to hold the values from database temporarily
SqlDataAdapter adapter =
new
SqlDataAdapter(cmd);
//open Database connection
conn.Open();
adapter.Fill(dt);
dataGridView.DataSource = dt;
foreach
(DataRow dr
in
dt.Rows)
{
j = j + Convert.ToDecimal(dr[
"Balance_Amt"
].ToString());
}
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
}
{
}
}
Attachment:
Capture.rar
Reply
Answers (
2
)
how to read a text file at real time
EnableRetryOnFailure() to the UseSqlServer cal