简体   繁体   中英

How to assign a data column value to specific word using C#

I have a field in my table in which I would like to set a string like “COMPLETE”. Initially the field is empty and I want to set it some kind of text like “COMPLETE” Here is what I have so far…

   string ID = GV_Action.Rows[0].Cells[1].Text;

    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);

    SqlCommand cmd = new SqlCommand("sp_Update", con);
    cmd.CommandType = CommandType.StoredProcedure;

    cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = ID;

    cmd.Connection = con;
    con.Open();
    cmd.ExecuteNonQuery();
    con.Close();

in my Strored procedure below i am using a default ID but would like to pass the paramter ID and not use the fixed value how can i do that? here is how i created the proc CREATE PROC sp_Update

AS

EXEC msdb.dbo.sp_start_job N'UpdateField';

GO

EXEC sp_Update

and here is job that i am calling when the procedure kicks off update MyTable

set Status = 'Complete' where Post_ID = 303

您可以通过以下方式直接从数据库中填充它:

SELECT Count(*), 'COMPLETE' AS MyColumn FROM MyTable

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM