Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
string strItem = GridView1.Rows[e.RowIndex].FindControl("txtItem").ToString();
        string strInvoiceNoFrm = GridView1.Rows[e.RowIndex].FindControl("txtInvoiceNoFrm").ToString();
        string strInvoiceNoTo = GridView1.Rows[e.RowIndex].FindControl("txtInvoiceNoTo").ToString();
        string strDetails = GridView1.Rows[e.RowIndex].FindControl("txtDetails").ToString();
        string strRemark = GridView1.Rows[e.RowIndex].FindControl("txtRemark").ToString();
        string strSrNo = GridView1.Rows[e.RowIndex].FindControl("lblSrNo").ToString();
        try
        {
            //Prepare the Update Command of the DataSource control
            string strSQL = "";
            strSQL = "UPDATE InvoiceDetails set Item = '" + strItem + "'" +
                    ",InvoiceNoFrm = '" + strInvoiceNoFrm + "'" +
                    ",InvoiceNoTo = '" + strInvoiceNoTo + "'" +
                     ",Details = '" + strDetails + "'" +
                     ",Remark = '" + strRemark + "'" +

                     " WHERE SrNo = '" + strSrNo + "'";
            SqlDataSource2.UpdateCommand = strSQL;
            SqlDataSource2.Update();
            ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Enquiry updated successfully');</script>");
        }
        catch { }
Posted
Comments
CPallini 22-Jun-11 9:16am    
I see a question title, a piece of (possibly unrelated) code without any explanation. Do you trust in our magic powers?
thatraja 22-Jun-11 9:33am    
He said Yes ;-)
:D
Rajeev Jayaram 19-Mar-13 5:25am    
That's Awesome :-)
Member 7979544 22-Jun-11 9:21am    
yes
Mohd Wasif 22-Jun-11 9:28am    
Please give data types of fields in table .

1 solution

Hi,

First of all, never ever use SQL code this way, this will open up a big hole for SQL Injections (http://en.wikipedia.org/wiki/SQL_injection[^]).

Anyway, I think you want to convert a SQL varchar to a SQL bigint because the SQL query returns that it cannot convert it from scratch, right?

So if you want to convert a varchar to a bigint in SQL, you could use the SQL function convert() (http://msdn.microsoft.com/en-us/library/ms187928.aspx[^]):
CONVERT(bigint, '123456789')

or as a single query executable by the SQL management studio:
SELECT CONVERT(bigint, '123456789')


I hope this helps.

Best regards and happy coding,
Stops
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900