16,021,285 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by r5five (Top 17 by date)
r5five
16-Mar-13 3:02am
View
i just pasted the code
r5five
14-Mar-13 14:44pm
View
ok I will upload my code, its a lengthy code I hope u wont get bored
r5five
14-Mar-13 2:23am
View
and the error is when I try using the dynamic search form
r5five
14-Mar-13 2:20am
View
unable to cast object of type Mainformdatatable to type system.data.dataview
r5five
14-Mar-13 1:48am
View
ok I managed to do that but after copying all the references, my program gets an error cannot cast mainform from system.data.view
r5five
13-Mar-13 2:16am
View
yes I did. after creating the setup files and installing the program, the coding in the installed folder can be easily read and edited by notepad
r5five
13-Mar-13 2:08am
View
no I did not use any hard coded file paths
r5five
12-Mar-13 14:25pm
View
what is the meaning of hard coded file paths
r5five
12-Mar-13 4:53am
View
yes I have its the whole project folder. I just tried running it from windows 7
r5five
9-Mar-13 2:12am
View
but how do I declare the code for the current selected row. using the above code I can set the current cell to a specified row and cell but how to set it automatically to a selected row
r5five
8-Mar-13 4:03am
View
I receive a #error
r5five
10-Feb-13 12:23pm
View
Oh and can you Please share with me how to Delete Selected Row Permanently from the DatagridView and database.sdf
r5five
10-Feb-13 12:13pm
View
I just tried it But it does not work. I think The problem is somewhere from loademployee() maybe there is something missing? When i tried ADAP.Fill, it insteads make a copy of everythin but it does show the new data, whereas ADAP.Update updates the selected data succesfully but does not show the new data
r5five
10-Feb-13 11:17am
View
The code is really not necessary but i will paste it, i have no problem with the edit button to pass data, the only problem is after i update the data, it gets saved but the data in the DataGridView is not Refreshed, I have to close the whole app and open again to see the edited data
r5five
5-Feb-13 4:13am
View
Deleted
seems like not all the code is getting pasted
r5five
5-Feb-13 4:09am
View
Deleted
I tried This Code But it does not work, the data gets filled into the text box in frmUpdate, but when i click update button it does not update but instead creates a copy of all the rows...??!!
this is the code in Form1 which contains the datagridview
private void Form1_Load(object sender, EventArgs e) { loadEmployee(); // TODO: This line of code loads data into the 'databaseDataSet.Mainform' table. You can move, or remove it, as needed.
this.mainformTableAdapter.Fill(this.databaseDataSet.Mainfo rm); // TODO: This line of code loads data into the 'databaseDataSet.Mainform' table. You can move, or remove it, as needed.
this.mainformTableAdapter.Fill(this.databaseDataSet.Mainfo rm); // TODO: This line of code loads data into the 'databaseDataSet.Mainform' table. You can move, or remove it, as needed.
this.mainformTableAdapter.Fill(this.databaseDataSet.Mainfo rm); }
public void loadEmployee() { SqlCeConnection con = new SqlCeConnection("Data Source=Database.sdf"); try { SqlCeDataAdapter ADAP = new SqlCeDataAdapter("Select Name, Age, Gender, Family_Member, Family_Member_Name, Shnong, Dong, Grand, Amount, Phone_Number, Date_Registered, Date_Recieved, Status from Mainform", con);
ADAP.Fill(databaseDataSet, "Mainform"); this.dataGridView2.DataSource = databaseDataSet.Tables["Mainform"];
} catch (Exception) { }
}
private void btoedit_Click(object sender, EventArgs e) { frmUpdate f2 = new frmUpdate(this); f2.Name = dataGridView2.CurrentRow.Cells[0].Value.ToString(); f2.Age = dataGridView2.CurrentRow.Cells[1].Value.ToString(); f2.Gender = dataGridView2.CurrentRow.Cells[2].Value.ToString(); f2.Family_Member = dataGridView2.CurrentRow.Cells[3].Value.ToString(); f2.Family_Member_Name = dataGridView2.CurrentRow.Cells[4].Value.ToString(); f2.Shnong = dataGridView2.CurrentRow.Cells[5].Value.ToString(); f2.Dong = dataGridView2.CurrentRow.Cells[6].Value.ToString(); f2.Grand = dataGridView2.CurrentRow.Cells[7].Value.ToString(); f2.Amount = dataGridView2.CurrentRow.Cells[8].Value.ToString(); f2.Phone_Number = dataGridView2.CurrentRow.Cells[9].Value.ToString(); f2.Date_Registered = dataGridView2.CurrentRow.Cells[10].Value.ToString(); f2.Date_Recieved = dataGridView2.CurrentRow.Cells[11].Value.ToString(); f2.Status = dataGridView2.CurrentRow.Cells[12].Value.ToString(); f2.passDgvValueToForm2(); f2.ShowDialog(); }
And this is the whole code in frmUpdate:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; using System.Data.SqlServerCe;
namespace HDR2 { public partial class frmUpdate : Form { public string Name, Age, Gender, Family_Member, Family_Member_Name, Shnong, Dong, Grand, Amount, Phone_Number, Date_Registered, Date_Recieved, Status; private Form1 f1;
public frmUpdate(Form1 f2) { InitializeComponent(); f1 = f2;
} public void passDgvValueToForm2() { NametxtUpdate.Text = Name; AgetxtUpdate.Text = Age; GendertxtUpdate.Text = Gender; FamilymembertxtUpdate.Text = Family_Member; FamilymembernametxtUpdate.Text = Family_Member_Name; ShnongtxtUpdate.Text = Shnong; DongtxtUpdate.Text = Dong; GrandtxtUpdate.Text = Grand; AmounttxtUpdate.Text = Amount; PhonenumbertxtUpdate.Text = Phone_Number; DateregisteredUpdate.Text = Date_Registered; daterecievedupdate.Text = Date_Recieved; StatuscbUpdate.Text = Status; } private void frmUpdate_Load(object sender, EventArgs e) {
}
private void btnUpdate_Click(object sender, EventArgs e) { update(); f1.loadEmployee(); }
private void update() { SqlCeConnection con = new SqlCeConnection("Data Source=Database.sdf"); con.Open(); using (SqlCeCommand cmd = new SqlCeCommand("UPDATE Mainform SET Name=@Name, Age=@Age, Gender=@Gender, Family_Member=@Family_Member, Family_Member_Name=@Family_Member_Name, Shnong=@Shnong, Dong=@Dong, Grand=@Grand, Amount=@Amount, Phone_Number=@Phone_Number, Date_Registered=@Date_Registered, Date_Recieved=@Date_Recieved, Sta
r5five
5-Feb-13 3:17am
View
Thats the problem, ive tried using some codes i found from the net but none of them work so the codings now are blank
Show More