My suggestion to you is set a breakpoint at int Eid and step through the code using the debugger. watch the values because this error means you have a null value.
Nevermind, set your query back to the way you had it originally. I was thinking of ename, eaddress etc as strings but they are variables. Sorry about that
But you haven't declared it as an actual SqlConnection object. It doens't know what it is. Just try it the way I'm telling you to. I have over 10 years experience in dot net development. Another user also mentioned this as well.
He's doing all this in code behind, his data in the gridview shows fine, he isn't able to write to the database. I told him to set break points and step through to make sure his events are actually firing. So far, he hasn't responded so I have to presume
he's working on it.
He's doing all this in code behind, his data in the gridview shows fine, he isn't able to write to the database. I told him to set break points and step through to make sure his events are actually firing. So far, he hasn't responded so I have to presume
he's working on it.
Ya.Sorry i not saw your answers ..but i think your last code is wrong.because that he was used in this line con.Open .So i think that he commanly used the sqlconnection and call need a time.But Why this code not updating?
Nevermind, set your query back to the way you had it originally. I was thinking of ename, eaddress etc as strings but they are variables. Sorry about that
Good listen buddy...............But Your query is working properly with just change where Sno='+"1"+'"
Member
4 Points
36 Posts
object reference not set to an instance of an object.
Nov 29, 2012 10:05 AM|rkoravi|LINK
Hi i didnt know where mistake pls anyone help me...
i need row updating in gridview asp.net c#...Thank you
All-Star
35218 Points
9955 Posts
Moderator
Re: object reference not set to an instance of an object.
Nov 29, 2012 10:15 AM|bbcompent1|LINK
My suggestion to you is set a breakpoint at int Eid and step through the code using the debugger. watch the values because this error means you have a null value.
All-Star
52673 Points
15717 Posts
Re: object reference not set to an instance of an object.
Nov 29, 2012 10:23 AM|oned_gk|LINK
Suwandi - Non Graduate Programmer
Member
4 Points
36 Posts
Re: object reference not set to an instance of an object.
Nov 29, 2012 10:24 AM|rkoravi|LINK
Hi, no null value in database y the error occur
Member
677 Points
240 Posts
Re: object reference not set to an instance of an object.
Nov 29, 2012 10:26 AM|msmk|LINK
Your update statement should look like this:
(I moved over the + symbols).
You should probably be using parameters though. This is not the safest way to pass in values to sql query
Member
4 Points
36 Posts
Re: object reference not set to an instance of an object.
Nov 29, 2012 11:11 AM|rkoravi|LINK
Hi frinds,
Its worked but no changes when update anyone can help me
Member
677 Points
240 Posts
Re: object reference not set to an instance of an object.
Nov 29, 2012 11:19 AM|msmk|LINK
Nevermind, set your query back to the way you had it originally. I was thinking of ename, eaddress etc as strings but they are variables. Sorry about that
All-Star
35218 Points
9955 Posts
Moderator
Re: object reference not set to an instance of an object.
Nov 29, 2012 11:22 AM|bbcompent1|LINK
You didn't define what con is, your connection object. Should be something like:
SqlConnection con = new SqlConnection(yourconnstring);
Member
4 Points
36 Posts
Re: object reference not set to an instance of an object.
Nov 29, 2012 11:30 AM|rkoravi|LINK
Hi bbcompent1 ,
ya (ie) sql connection string
All-Star
35218 Points
9955 Posts
Moderator
Re: object reference not set to an instance of an object.
Nov 29, 2012 11:32 AM|bbcompent1|LINK
But you haven't declared it as an actual SqlConnection object. It doens't know what it is. Just try it the way I'm telling you to. I have over 10 years experience in dot net development. Another user also mentioned this as well.
All-Star
35218 Points
9955 Posts
Moderator
Re: object reference not set to an instance of an object.
Nov 29, 2012 11:35 AM|bbcompent1|LINK
You have your cmd right however you dont' have an actual connection strin in the code you show above. This is what I usually do:
Contributor
4554 Points
1768 Posts
Re: object reference not set to an instance of an object.
Nov 29, 2012 12:18 PM|RameshRajendran|LINK
Hai
Please check your Eid value...and Also verify that you have assign DataKey in gridview
But i think The gridview rowupdating event was not fired.Please check this thread
http://forums.asp.net/t/1800251.aspx/1
Thank you...
All-Star
35218 Points
9955 Posts
Moderator
Re: object reference not set to an instance of an object.
Nov 29, 2012 12:44 PM|bbcompent1|LINK
He's doing all this in code behind, his data in the gridview shows fine, he isn't able to write to the database. I told him to set break points and step through to make sure his events are actually firing. So far, he hasn't responded so I have to presume he's working on it.
Contributor
4554 Points
1768 Posts
Re: object reference not set to an instance of an object.
Nov 29, 2012 01:12 PM|RameshRajendran|LINK
Ya.Sorry i not saw your answers ..but i think your last code is wrong.because that he was used in this line con.Open .So i think that he commanly used the sqlconnection and call need a time.But Why this code not updating?
Contributor
4554 Points
1768 Posts
Re: object reference not set to an instance of an object.
Nov 29, 2012 01:32 PM|RameshRajendran|LINK
Hey guy
Check this sample code
Good luck buddy.........
Contributor
4554 Points
1768 Posts
Re: object reference not set to an instance of an object.
Nov 29, 2012 01:38 PM|RameshRajendran|LINK
Good listen buddy...............But Your query is working properly with just change where Sno='+"1"+'"
All-Star
52673 Points
15717 Posts
Re: object reference not set to an instance of an object.
Nov 29, 2012 09:00 PM|oned_gk|LINK
Before
Declare con inside this event.
Suwandi - Non Graduate Programmer
All-Star
35218 Points
9955 Posts
Moderator
Re: object reference not set to an instance of an object.
Nov 30, 2012 06:45 AM|bbcompent1|LINK
Precisely, this is what we have been telling the OP since page one.
Member
60 Points
24 Posts
Re: object reference not set to an instance of an object.
Dec 03, 2012 08:43 PM|CommDev|LINK
Hi rkoravi,
From your code, I have another suggestion that you should add “try … catch …” to avoid the “conn” is not closed properly.