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
vincent
NA
1
0
Datagrid problems
Sep 12 2007 5:11 AM
Hey.
First of all let me introduce myself because this is my first post.
My name is vincent or crazy as most people call me.
Now for the problem.
We are working on a project for school.
This is a C# project in combination with an Access Database.
Most of the functions are working and we're closing on finishing the project.
The only bottleneck is with a datagrid view.
With this datagridview we insert/edit/delete rows.
But we just cant get it to work.
I`m currently working with UserAddedRow where the insert query is located.
But when we try to insert a value in the first row i get the error that an object reference is not set to an instance of an object.
We have tried various things to fix it like giving the second row a default value, but this din't seem to work.
The datagridview only has 2 rows.
- Project destription (default text)
- Status (Dropdownbox)
We use this code:
private void dgvProjects_UserAddedRow(object sender, DataGridViewRowEventArgs e)
{
Companys tmp = cbxCompanyName.SelectedItem as Companys;
try
{
string qryInsertSecValues = "INSERT INTO Projects (Cid, Description, Status) VALUES (" + tmp.ID.ToString() + ", '" + e.Row.Cells[0].Value.ToString() + "', '" + e.Row.Cells[1].Value.ToString() + "')";
OdbcCommand myodbccommand = new OdbcCommand(qryInsertSecValues);
myodbccommand.Connection = TabStripApp.Singleton.Connector.Connection;
myodbccommand.ExecuteNonQuery();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.ToString());
}
}
With this i hope i have supplied enough information.
Does anyone know the problem or how to fix it ?
Greetings,
Vincent
Reply
Answers (
1
)
Create Report in C#
C# Application