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
Srm Matin
NA
38
2k
Datagridview problem when form load
Apr 20 2020 11:59 PM
hi .. I Have Problem When i click save button in my winform and want save decrypted sql value into database , everything is ok but when i want add this value to datagridview row and refresh my rows Whit this value and row , DATAGRIDVIEW show other rows whit this ....EXAM : i have 3 recrord {1,2,3} , and i save one recorde {4} when i call datagridview fill in my form load an want refresh that , show {1,2,3,4}{1,2,3,4} - means duplicate row
void
loaddgvdata() {
try
{
sda.SelectCommand = command;
sda.SelectCommand.Connection = connection;
sda.SelectCommand.CommandText =
"SELECT * FROM personnal"
;
sda.Fill(ds,
"personnal"
);
dgpersonal.DataSource = ds;
dgpersonal.DataMember =
"personnal"
;
dgpersonal.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgpersonal.Columns[0].HeaderText =
"????? ??????"
;
dgpersonal.Columns[0].Frozen =
true
;
dgpersonal.Columns[1].HeaderText =
"???"
;
dgpersonal.Columns[2].HeaderText =
"???"
;
dgpersonal.Columns[3].HeaderText =
"???"
;
dgpersonal.Columns[4].HeaderText =
"???"
;
dgpersonal.Columns[5].HeaderText =
"???"
;
dgpersonal.Columns[6].HeaderText =
"???"
;
dgpersonal.Columns[7].HeaderText =
"???"
;
dgpersonal.Columns[8].HeaderText =
"???"
;
dgpersonal.Columns[9].HeaderText =
"???"
;
dgpersonal.Columns[10].HeaderText =
"???"
;
dgpersonal.Columns[11].HeaderText =
"???"
;
connection.Open();
dr = command.ExecuteReader();
int
rowindex = 0;
while
(dr.Read()) {
var inputname = dr[
"name"
].ToString();
var passwordname = password;
var resultname = AesCryptography.DecryptText(inputname, passwordname);
dgpersonal.Rows[rowindex].Cells[1].Value = resultname;
var inputlname = dr[
"lname"
].ToString();
var passwordlname = password;
var resultlname = AesCryptography.DecryptText(inputlname, passwordlname);
dgpersonal.Rows[rowindex].Cells[2].Value = resultlname;
var inputdadname = dr[
"dadname"
].ToString();
var passworddadname = password;
var resultdadname = AesCryptography.DecryptText(inputdadname, passworddadname);
dgpersonal.Rows[rowindex].Cells[3].Value = resultdadname;
var inputbirth = dr[
"birth"
].ToString();
var passwordbirth = password;
var resultbirth = AesCryptography.DecryptText(inputbirth, passwordbirth);
dgpersonal.Rows[rowindex].Cells[4].Value = resultbirth;
var inputidnum = dr[
"idnum"
].ToString();
var passwordidnum = password;
var resultidnum = AesCryptography.DecryptText(inputidnum, passwordidnum);
dgpersonal.Rows[rowindex].Cells[5].Value = resultidnum;
var inputidmeli = dr[
"idmeli"
].ToString();
var passwordidmeli = password;
var resultidmeli = AesCryptography.DecryptText(inputidmeli, passwordidmeli);
dgpersonal.Rows[rowindex].Cells[6].Value = resultidmeli;
var inputtahsil = dr[
"tahsil"
].ToString();
var passwordtahsil = password;
var resulttahsil = AesCryptography.DecryptText(inputtahsil, passwordtahsil);
dgpersonal.Rows[rowindex].Cells[7].Value = resulttahsil;
var inputjob = dr[
"job"
].ToString();
var passwordjob = password;
var resultjob = AesCryptography.DecryptText(inputjob, passwordjob);
dgpersonal.Rows[rowindex].Cells[8].Value = resultjob;
var inputpay = dr[
"pay"
].ToString();
var passwordpay = password;
var resultpay = AesCryptography.DecryptText(inputpay, passwordpay);
dgpersonal.Rows[rowindex].Cells[9].Value = resultpay;
var inputmony = dr[
"mony"
].ToString();
var passwordmony = password;
var resultmony = AesCryptography.DecryptText(inputmony, passwordmony);
dgpersonal.Rows[rowindex].Cells[10].Value = resultmony;
var inputaddres = dr[
"addres"
].ToString();
var passwordaddres = password;
var resultaddres = AesCryptography.DecryptText(inputaddres, passwordaddres);
dgpersonal.Rows[rowindex].Cells[11].Value = resultaddres;
rowindex++;
}
}
catch
(SqlException ex) {
MessageBox.Show(ex.Message);
}
finally
{
connection.Close();
dr.Close();
}
}
This is my code and when click save button , call loaddgvdata()
Reply
Answers (
7
)
select value from row-1 MS SQL from multiple table
Retrieve email id from full email