hih
saw your post, it really great, but if i have web service, how am i going to call the web service web method to the datagridview and do the update, insert and delete???cause i am only am be to retrieve the data to the datagridview
for delete, i want to delete in the datagridview, meaning each row got it own delete button
please provide me with the code…..

Bhaia,
thanks,it was really useful to me.
data is showing accurately while form load. but in button click event for update, its showing an error. which is:
”
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
”

Thanks bhaia,
I have created one column ‘cust_ID’ primary key in DB. Now its working perfectly.
But i tried to use a textbox in the form where i will give a customer_ID and also a button. So, if i click the button then it will show the result in DataGrid, against the customer_ID which will be given in the textbox. For this, i used where condition in the query and left the rest of the code as before(similar to urs). But unfortunately its not working. Its showing the Column Headers but no result.
help me out again…
:-)

I want to perform Edit , Delete n Update in dataGridView n data should b saved in DB ,, Used Ur code bt the update so far don in GRIDVIEW only and its nt saved in DB .., It is very easy to perform Update Delete in WEB Application ..,, Bt here it is hectic ..,, Want to complete the task ..,, Help m out of it ..,, Hoping for a reply soon !!

private void Form6_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the ‘masterDataSet.DBstore’ table. You can move, or remove it, as needed.
//this.dBstoreTableAdapter.Fill(this.masterDataSet.DBstore);

Bhaia,
I have done Insert,Update,Delete in dataGridView in the same way as urs.
But now i want to take a dataGridView where i will add 3 column(name,address,Phone) manualy. Is it possible to do the same things(insert,update,delete) with database in this Gridview. how ??
all i know is that: i have to bind it with object. but how?

Update for the entire row is happening ..,, But for a single column it throws an exception ..,, Can U sort out this problem .. Delete is also not working properly ..,, There also throws an exception ..

Dear Sir,
how can i add the reference of system.configuration, i m unable to ignore this error if u have time to solve my problem then reply step by step i have download code but no success to remove the errror.
Regards,
Arpan

To add a reference in Visual C#
# In Solution Explorer, right-click the project node and click Add Reference.
# In the Add Reference dialog box, select the tab indicating the type of component you want to reference.

Thanks for your code for update from Grid view to database…. But unfortunately when i debugging this code an error is coming ” System.Data.DataTable’ is a ‘type’ but is used like a ‘variable’ ”
can you please suggest that how can i improve that…….

Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information……….When i click update button i got this exception can u tell me why???

my first form is datagridview …side buttons is..add ,edit, delete,and close…now i want add some details then click add button then open another form…..now insert the data from add form….now add form close after inserted data…..i want automatic refresh the form1……

this will not work. When you click add button , close the datagrid form, open up the add data form. Now, when you close the add data form, open the datagrid form again automatically. I have done this kind of stuffs with vb6, has not done it with C#. it should work somehow.

the better idea is create a new function in datagridform, then shift(cut & paste) the code which you use to fill datagridview in a new function(means refactor the code to function).
Now when you close the add form call that function.

In case you are adding row by row, then clear the rows of datagridview first in the function

hello..
i want to add, delete, update in my C# forms through DLL… adding , deleting , updating textboxes is very simple if we write codes on buttons. but i want to learn that how we doing this through DLL. plz share some knowledge with me..

My Name is Raman ,as per the above comments , I understand you are very good at .net
I am new to win app, but good SQL server,
Can you tell me , I Can Solve the below querdy.

I have 5 tables and one datagridview , which display the information from 5 different tables,
now user is allowed add/update/delete opration in the grid with new information.
user can add or update or delete the datagridview row.
I have single button “SAVE” which save the data in the database. how can i set , update or insert or delete operation on one “SAVE” button.

First of all thanks for such a code,because i researched the entire google but found no single code for this ins,upd & del.Now i just have a doubt,i used part of ur code to do just a delete opr in datagridview.when i update the database,it keeps on giving the same error that,”Object reference not set to instance of an object.NullReferenceException”.Am getting mad trying alternatives for this error for 2 days.pls help resolve.
here it is:

Salam bhai,
I’ve done each and every step as you told here..but still i am getting an error as”The name ‘ConfigurationManager’ does not exist in the current context” but i am getting an option of “configuration setting”..when am trying to run with that there’s a run time error as “sql exception was unhandled”..I wanna use my own Database here..please help..
regards,
Aatif.

i am making my gridview in window form when i update my colum value
this type of message i am getting.
message—“Dynamic sql generation for the update command is not supported against a select command that does not return any key colum information”

private void pescontact_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the ‘database1DataSet1.contact’ table. You can move, or remove it, as needed.

// TODO: This line of code loads data into the ‘database1DataSet1.contact’ table. You can move, or remove it, as needed.
//
// TODO: This line of code loads data into the ‘database1DataSet2.contact’ table. You can move, or remove it, as needed.

I got table which is relation table for two another tables, so i got there only 2 columns with foreign key numbers and 1 column with value. Is possible to change some numbers in some columns to names from another table?

I was designed a windows application form named as updatecustomerinvoice.in this form my issue is.with the name of companyname combobox is there if i choose any companyname name from combobox(cmb_companyname).it has to display the remaining textboxes.i will display my tables here.
Tbl_report1 columns:
Invoiceno,particulars,quantity,perprice,amount,invoicedate,ondate,invoiceid,orderno
Tbl_report2 columns:
Compname,compaddress,invoiceno(primarykey),orderno,ondate,invoicedate,amountstatus,netamount,netvat,tamount
Tbl_customer columns:
Custid,custname,custaddress,custcity,custstate,custstdcode,custphoneno,custmobileno

This is one of the most useful piece of code that I have come across on the net in a long long time. It has saved hours and hours of my time. Just wanted to know how to validate data while saving, can we get individual values and validate them eg do not allow negative values or values above a cut-off level etc

I wnt to display Admision no with checked box’s and checked means Present,unchecked means Absent.how to do These values are will be directly insert aswell as update
.
.
Plz help me how to Do this.Send Sample code for me.

its the first time i m working with the datagridview… i m not able to insert the data .. actually its being inserted in the datagridview on the screen but my database mdb file is still empty…
even if i dont enter the records and fire a select query it is not even reacting to it.. help me soon…….Mr.rahim

i want to apply query on datagrid view acc to user need..
for eg: user enter name in textbox and corresponding to dis textbox value related rows are selected and data is fetch in grid view..
pls help.
its urgent..

hello sir,
i want to now when we give command as
sqlDataAdapter.Update(dataTable);
this will require update command text .. so i gave update command text as “update bname=? where id=?”
and for id i got value as e.currentRowIndex, so its updating only 1 row ..
…

how to update all record at once ?

and is their any way to freeze particular row from updating and deleting ?

Hi Rahim,
I am getting “Dynamic SQL generation is not supported under multiple Base Tables”, the reason of the error is I am Joining multiple tables to get the data in the Data grid. Now how should i write the insert command to insert into one table from the Data grid values.

I could not figure the Parameters for that Insert commnad Can you please let me know the syntax for the Insert and Update commands when we use multiple tables in the select to show the data in the Datagrid.

Hi.
i m Tripti.
can we add a column in sqlserver database at run time using datagridview. like if we add a col in data gridview at runtime it must reflect the changes in sql server database’ table.
is it possible?

code that i used to add col in datagrid at run time..
DataGridViewTextBoxColumn clsCol1 = new DataGridViewTextBoxColumn();
clsCol1.HeaderText = “Column 1”;
clsCol1.ValueType = typeof(System.String);
this.dataGridView1.Columns.Add(clsCol1);

HI sir,
i’m filtering the data’s from the sql table and dislplaying in datagridview , now i want to save the filtered content displayed in the datagridveiw in another new sql table. pl help me how to perform it using c#.net. pl send the code to pradeepnair@gmail.com

i want to insert grid view data to another table.and delete from current table in Sql Database..here is my code…its always insert row no to table not the column value..please help me..current table is jobmain i want to job main row data to jobcompleted.and delete from jobmain.

hello sir…….
i used your whole code…..but still i found run time error on updating and deleting……..
error is
“object refrence not set to an instance of object”
plz……tell me……the reason of this error……
plz reply me soon……
Thanx…..!!!!

salam rahem
i write your code in my project but i have a single error in this line
connectionString = ConfigurationManager.AppSettings[“connectionString”];
underlined “ConfigurationManager” this word please tell me its solution?
thanks

Hello sir….
i used your code in my application for insert,delete and update from datagridview to sql but it giving an error
“The name ‘ConfigurationManager’ does not exist in the current context”
so please give a solution

When i click on Add\update button, a dialog box showing syntax error INSERT INTO and when i click on Delete button it also shows a dialog “Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column information”
why it is happening like please give me reply….

hi rahim sir .. please i need code of update and delete from gridview but as u given above code that is not understanding to me.. i had dowloaded your above source also.. but how to restore mdf and ldf files in sql server

hi i want a code to add details in my database using c#windows form apllication in these from it contains add button when i entered data in textboxes than click add button it will added to the data base plzz rply me

here my code is

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;

private void Form2_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the ‘departmentDataSet3.employee’ table. You can move, or remove it, as needed.
this.employeeTableAdapter2.Fill(this.departmentDataSet3.employee);
// TODO: This line of code loads data into the ‘departmentDataSet2.employee’ table. You can move, or remove it, as needed.
this.employeeTableAdapter1.Fill(this.departmentDataSet2.employee);
// TODO: This line of code loads data into the ‘departmentDataSet.employee’ table. You can move, or remove it, as needed.
this.employeeTableAdapter.Fill(this.departmentDataSet.employee);
// TODO: This line of code loads data into the ‘departmentDataSet1.DEPARTMENT’ table. You can move, or remove it, as needed.
this.dEPARTMENTTableAdapter.Fill(this.departmentDataSet1.DEPARTMENT);
}

hey…..i want to ask that for the value “11.40” i have used decimal(18,2) but whenever i try to update the data at that time it’s give me the error like conversion faild when converting the nvarchar value “11.40” to data type int.
how can i solved?plz rply me

hey..I have created one page in vb.net in which i have taken 1 grid view which shows notification about person who will donate amount on particular day/date. Now if person donate some amount monthly and if he paid amount then i want to remove his notification and also the notification should get display in next month. please reply

hii..I have created one page in vb.net in which i have taken 1 grid view which shows notification about person who will donate amount on particular day/date. Now if person donate some amount monthly and if he paid amount then i want to remove his notification and also the notification should get display in next month. please reply

I have created one page in vb.net in which i have taken 1 grid view which shows notification about person who will donate amount on particular day/date. Now if person donate some amount monthly and if he paid amount then i want to remove his notification and also the notification should get display in next month. please reply..