ADO.NET :: Getting Error In Updation Through Gridview

Aug 9, 2010

i am trying to update table but geeting error

"System.Data.OleDb.OleDbException: Syntax error in UPDATE statement."

here is my code :

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string Id = GridView1.DataKeys[e.RowIndex].Values[0].ToString();
TextBox txtDate = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDate"));
TextBox txtAction = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtAction"));
TextBox txtScrip = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtScrip"));
TextBox txtnBuy = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtnBuy"));
TextBox txtSell = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtSell"));
TextBox txtremarks = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtremarks"));
TextBox txtTarget = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtTarget"));
TextBox txtDifference = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDifference"));
TextBox txtProfit = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtProfit"));
con.Open();
OleDbCommand cmd = new OleDbCommand("UPDATE performance set ndate='" + txtDate.Text + "',Action='" + txtAction.Text
+ "',Scrip='" + txtScrip.Text
+ "',nbuy='" + txtnBuy.Text
+ "',nsell='" + txtSell.Text
+ "',remarks='" + txtremarks.Text
+ "',Target='" + txtTarget.Text
+ "',Difference='" + txtDifference.Text
+ "',nprofit='" + txtProfit.Text
+ "' WHERE nid=" + Id, con);
cmd.ExecuteNonQuery();
con.Close();
GridView1.EditIndex = -1;
bind();
}

<asp:TemplateField HeaderText="Date">
<ItemStyle Width="100px" />
<EditItemTemplate>
<asp:TextBox ID="txtDate" runat="server" Text='<%#Bind("ndate")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("ndate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action">
<ItemStyle Width="100px" />
<EditItemTemplate>
<asp:TextBox ID="txtAction" runat="server" Text='<%#Bind("Action")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%#Eval("Action") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Scrip">
<ItemStyle Width="100px" />
<EditItemTemplate>
<asp:TextBox ID="txtScrip" runat="server" Text='<%#Bind("Scrip")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%#Eval("Scrip") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Buy Level">
<ItemStyle Width="100px" />
<EditItemTemplate>
<asp:TextBox ID="txtnBuy" runat="server" Text='<%#Bind("nbuy")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%#Eval("nbuy") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sell Level">
<ItemStyle Width="100px" />
<EditItemTemplate>
<asp:TextBox ID="txtSell" runat="server" Text='<%#Bind("nsell") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%#Eval("nsell") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Remarks">
<ItemStyle Width="100px" />
<EditItemTemplate>
<asp:TextBox ID="txtremarks" runat="server" Text='<%#Bind("remarks") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%#Eval("remarks") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Target">
<ItemStyle Width="100px" />
<EditItemTemplate>
<asp:TextBox ID="txtTarget" runat="server" Text='<%#Bind("Target") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%#Eval("Target") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Difference">
<ItemStyle Width="100px" />
<EditItemTemplate>
<asp:TextBox ID="txtDifference" runat="server" Text='<%#Bind("Difference") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label10" runat="server" Text='<%#Eval("Difference") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Profit">
<ItemStyle Width="100px" />
<EditItemTemplate>
<asp:TextBox ID="txtProfit" runat="server" Text='<%#Bind("nprofit") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%#Eval("nprofit") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<EditItemTemplate>
<asp:LinkButton ID="link1" runat="server" Text="Update" CommandName="update"></asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" Text="Cancel" CommandName="cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton4" runat="server" Text="Edit" CommandName="edit"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
Text="Delete"></asp:LinkButton>
<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" ConfirmText="Are You Sure Want to Delete" TargetControlID="LinkButton1">
</ajaxToolkit:ConfirmButtonExtender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#9cd3fa" />
<FooterStyle BackColor="#CCCC99" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>

View 4 Replies


Similar Messages:

Web Forms :: Gridview Updation Of Record Using Stored Procedure?

Sep 21, 2010

i have bind griview dataSource with Store procedure having join of 3 table how can i update this gridview data using stored procedure?

View 5 Replies

AJAX :: Updation In Gridview Using XmlHttp Object Doesn't Work

Sep 24, 2010

I have many divs in 1 page and each div consists of a gridview, the gridview is loaded by making AJax calls. On load of the page, all the grid load data properly. But now when i update any row in either of the grids, and make a call to the javascript that loads the grid in the page, it doesn't work rightly. Wat are the options to update/refresh the grid.

View 1 Replies

Forms Data Controls :: GridView Row Index On Button Click For Updation?

Jun 14, 2010

I have GridView with no data source. That I have persisted in memory.When editing row, I have fetch data to ModalPopup. When I edit data on ModalPopup using button click, how to find row index?I mean, how to find which row has been updated?

View 15 Replies

Reg Storedprocedure Updation Not Working?

Nov 8, 2010

I have a C# DotNet application and an SP of SQL Server 2005. I had made changes to the SP. I found that the connection string of database in the web.config also is correct and it is pointing to the same database in the same server but after changing the SP and checking form front end I am not able to get the updated SP results. After changing the SP do we need to build dll of middle tier again? What all changes I need to make. When I run the SP individually it is giving correct updated results. i had done IISRESET also after chnaging the SP.

View 1 Replies

MVC :: Database Updation With 3 Tables?

Feb 24, 2011

I have 3 tables and I need to display ListBox and need to have facility for add/update facility. Here are the tables

Table 1 - PROJECT
Table 2- PROJECT_PRODUCTS
Table 3 - PRODUCTS

Now I have to Display PROJECT table for creating/editing and while doing it I would like to display ListBox(MultiSelect) for Products and I would like to know how can I implement this for editing?

View 2 Replies

C# - Jquery Events Are Not Working/firing After The Updation In UpdatePanel?

Jul 10, 2010

I have got an issue after updation in UpdatePanel. The issue is the jquery events are not working/firing after the updation in UpdatePanel. At first time, the jquery events work, but not after the updation in UpdatePanel. If I remove the UpdatePanel, the problem is solved. But I have to use the UpdatePanel.

View 1 Replies

Web Forms :: Updation Not Happening Correctly - Stores Value As 0 In Database

Jan 15, 2012

I have a gridview with a select command.. When user selects a row.. I need to populate 4 dropdownlists with the values in gridview, dropdownlist which are also populated at page load event...

Though there is value in the dropdownlist when i try to update it selects 0th value.. Since while updating i use drptask.selectedvalue.tostring() since i am saving int values in database

It stores value as 0 in database..

View 1 Replies

Sending Email Verification Link With Database Updation

Jan 3, 2012

i have popup on my webform with name and email id submit button,So when u click on submit button the name n email is entered into SQLSERVER database.As user click on submit a verification link should be sent to him table named "SUBSCRIBE" in database having columns :Name, Email, Date Time,Validated,ValidationEmailSent,Validation code.where name n email will come from as user entered....but others has to b generated. where

validation=if clicked on link den 1 otherwise 0;
validation Email = if email id is proper value is 1 not proper value should be 0;
validation code is ramdom no;

values of this 3 columns will b updated in database as per user response. How to write code for this problem as i have never used database sql server???

View 4 Replies

Web Forms :: LINQ CRUD Operations - How To Perform Updation

Oct 21, 2015

How to do CRUD in LINQ?

how to perform updation using linq where i have multiple conditions for for single row and updating multiple fields to that row?

View 1 Replies

Forms Data Controls :: Database Is Updated The Updation Must Be Availabe To All The Users Automatically

Jul 29, 2010

Lets take an example of online ticket booking system. Many users could be booking the tickets at any point of time. a GridView displays the list of Allotted and Free seats If a seat gets booked, this information must get updated in all the opened pages in user's browser. User need not require to refresh the page to see if a seat is booked or not Should i put GridView in update panel and keep looking into the databse constantly ??? This could turn out to be a heavy work if databse is too large any other alternative?? or should i stick with the above approach....?

View 10 Replies

Forms Data Controls :: Error - "Input String Was Not In A Correct Format." Error When Trying To Sort Gridview

Jan 21, 2011

I have gridview control that has data binded by using EF. Whenever I try to sort my gridview I get this error: "Input string was not in a correct format." This error points to the following line of code: "int index = Convert.ToInt32(e.CommandArgument);"

AdministracijaVrstaAktivnosti.aspx

[Code]....

AdministracijaVrstaAktivnosti.cs

[Code]....

I'm not sure what do I have to fix if I want to sort the columns.

If I bind the data manually what is the code for codebehind to allow sorting for particular columns.

View 3 Replies

Oracle Error When Selecting From Gridview That Is Bound To Another Gridview?

Oct 23, 2010

I've been working on a webform to pull data from an oracle database v10. I can create a gridview1 with Selection enabled and it will populate with data without a problem. However when I create a second gridview and bind with a control to the first gridview, I get the following error at runtime when I click on one of the Selects.

Exception Details:
Oracle.DataAccess.Client.OracleException: ORA-00936: missing expressionVS 2010.
[code]...

View 4 Replies

Get An Error While Editing Gridview?

Jul 21, 2010

I have a gridview with edit and delete. When i click Edit, I donot get all the textboxes. I just get 1. on top of that, when I try to update anything in that textbox, I get object Reference not set to an instance of object. my aspx for gridview is:

<asp:GridView ID="grdItems" runat="server" AllowSorting="True"
BackColor="White" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px"
CellPadding="4" ForeColor="Black" GridLines="Vertical" width="670px" OnRowCancelingEdit="grdItems_RowCancelingEdit" OnRowEditing="grdItems_RowEditing" OnRowUpdating="grdItems_RowUpdating" DataKeyNames="rowid" AutoGenerateColumns="False" OnRowDeleting="grdItems_RowDeleting" Font-Size="Smaller" ShowFooter="True" OnRowCreated="grdItems_RowCreated">
<Columns>
<asp:TemplateField HeaderText="ROWID" SortExpression="rowid" Visible="False">
[code]...

View 2 Replies

DataSource Controls :: SSIS Job Failed With Error Error Code: 0x80004005 OLEDB Error

Jun 6, 2010

Error:
Executed as user: MACSTEELUSA.COMsa. ...9.00.3042.00 for 32-bit Copyright (C) Microsoft Corp 1984-2005. All rights reserved. Started: 8:00:17 PM Error: 2010-06-02 20:00:18.56 Code: 0xC0202009 Source: CRM_ORACLE_ARSUMMARY Connection manager "SourceConnectionOLEDB" Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80004005 Description: "Oracle client
and networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3.3 or later client software installation. Provider is unable to function until these components are installed.". End Error Error: 2010-06-02 20:00:18.58 Code: 0xC020801C Source: Data Flow Task Source - Query [1] Description: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireCon... The package execution fa... The step failed.

Tasks Taken:Went to this folder checked for tnsnames.ora file but it is in good shape.

C:ORACLEproduct11.2.0client_1
etworkadmin

View 2 Replies

C# - Error Paging And Editing In Gridview

Oct 14, 2010

I had gridview which retrieve Products from database by sqldatasource1 ,and my manager asked me to filter this gridview by DDL to filter gridview with specfic Model ,I add some function on gridview as edit,paging .I did my code well and gridview filtred by the Model_Id which come from DDL .But when I tried to edit any product or navigate through paging I faced this error (The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. )when paging ,And this for editing (The GridView 'GridView1' fired event RowEditing which wasn't handled.)

protected void Page_Load(object sender, EventArgs e)
BindGridFunction();
[code]...

View 1 Replies

AJAX :: Getting 404 Error - Running Gridview

Dec 5, 2010

I have a master page with an update panel. I have stripped out all the code apart from updating a label with the time

[Code]....

code behind

[Code]....

When the timer event is firast fired then the label updates with the time, however when the timer event is fired a second time ( 10 secounds later ) I get a 404 error. I was running a gridview in this but have stripped back to a label to try and find out why this is occurring.

View 1 Replies

C# Excel To Gridview OleDB Error

Dec 3, 2010

I got an error about OleDB. I just want my excel file import to Gridview. Here is my code.

string connstr =
"Provider=Microsoft.Jet.Oledb.4.0;Data
Source=C:a.xls;Extended
Properties=Excel 8.0;HDR=YES;IMEX=1";
OleDbConnection conn = new OleDbConnection(connstr);
string strSQL = "Select * from [Sheet1$]";
OleDbCommand cmd = new OleDbCommand(strSQL, conn);
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();

When i build project there is no error but when i run this project i got an error like this:

System.ArgumentException:Format of the
initialization string does not conform
to specification starting at index 47.
Line 21: string connstr =
"Provider=Microsoft.Jet.Oledb.4.0;Data
Source=C:a.xls;Extended
Properties=Excel 8.0;HDR=YES;IMEX=1";
Line 22: Line 23:
OleDbConnection conn = new
OleDbConnection(connstr);

How can i fix this?

View 1 Replies

C# - Error In Gridview When AllowPaging = True

Jan 19, 2011

i have gridview in my asp.net webform.

i bind my database to gridview like this:

SQL = "SELECT id,Fname,Lname FROM MEN";
dsView = new DataSet();
adp = new SqlDataAdapter(SQL, Conn);
adp.Fill(dsView, "MEN");
adp.Dispose();
GridView1.DataSource = dsView.Tables[0].DefaultView;
GridView1.DataBind();

and this i put in the gridview: allowPaging = true

its show the data in the grid, but if i press to page 2..3..

and i got this error:

The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.

View 2 Replies

Convert GridView To Excel (Error)

Aug 11, 2011

I have what would seem like a fairly straightforward task: Export a report (GridView) to a spreadsheet, so that the client (user) can use the data elsewhere. I thought I found a very elegant solution. Here is the code:

Code:
Protected Sub btnWrite2Exell_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnWrite2Exell.Click
Response.Clear()
Response.AddHeader("content-disposition", "attachment; filename=FileName.xls")
Response.Charset = ""

[Code] ...

With a little putsing I got it to work, which is good, EXCEPT that it precedes opening the spreadsheet with a warning that looks like this:

View 10 Replies

Web Forms :: Error In PDF Conversion From Gridview?

Dec 31, 2012

i have used the same coding that u posted in ur site..

but the problem is that it is converting to pdf without the colum header contain means like customer id and name etc is not showing in pdf file..

it is showing the all other row data..

View 1 Replies

VS 2008 DeleteCommand Error With Gridview Sqldatasource?

Oct 2, 2010

I typically don't use the sqldatasource control but trying it out and can't seem to get the delete function working. It doesn't seem to be passing a parameter to my stored procedure. The error I get is: Procedure or function 'sp_DeleteCraigsListEntry' expects parameter '@craigslist_search_id', which was not supplied. Any thoughts?

Code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="ds1" CellPadding="4" DataKeyNames="craigslist_search_id"
ForeColor="#333333" GridLines="None" >
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:CommandField DeleteText="x" ShowDeleteButton="True" />
<asp:BoundField DataField="craigslist_search_id" HeaderText="ID"
InsertVisible="False" ReadOnly="True" SortExpression="craigslist_search_id" />
<asp:BoundField DataField="craigslist_search_value" HeaderText="Search Value"
SortExpression="craigslist_search_value" />
<asp:BoundField DataField="craigslist_Search_entry_dt" HeaderText="Entry Dt"
SortExpression="craigslist_Search_entry_dt" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />............

View 1 Replies

Web Forms :: How To Intercept An Error During A Update Of Gridview

Mar 24, 2010

i hava a gridview, with an sqldatasource control, if an update event goes to faili want intercept the error and manage ithow can i do? i cannot find the error event in gridview

View 2 Replies

AJAX :: Error While Using Collapsible Panel In Gridview

Oct 20, 2010

I am using a grid view as a child control inside a grid view and using an collapsible panel extender to show and hide the child grid.
Here is my code
[Code]....
I am getting the following error:
Microsoft JScript runtime error: Sys.InvalidOperationException: Two components with the same id 'cpe' can't be added to the application.

View 6 Replies

C# - Both DataSource And DataSourceID Are Defined Error Using With GridView

Jan 26, 2011

But it's different situation on gridview.

<asp:GridView ID="Grid_Goster" runat="server" AutoGenerateColumns="False" CellPadding="4"
DataSourceID="SqlDataSource3" ForeColor="#333333" GridLines="None"
Height="144px" Width="316px">
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:SqlServerCstr %>"
SelectCommand="SELECT * FROM [AVUKAT]"></asp:SqlDataSource>

And i get error like this: Both DataSource and DataSourceID are defined on 'Grid_Goster'. Remove one definition. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Both DataSource and DataSourceID are defined on 'Grid_Goster'. Remove one definition. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using And in my .cs file there is code like this.

SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
Grid_Goster.DataSource = dr;
Grid_Goster.Visible = true;

i think this code works correctly. How can i solve this DataSource and DataSourceID problem?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved