Member Avatar for CriticalError

Hi guys I got a table called rc_Pages then I got a column called pName (Pages Name) and now I have made a new column called pCategory (Page Category). Since there are like 60 pages and updating the pages manually can be a big issue. I need to set the pCategory values depending on the pName.

So say a page starts with "C-Sharp" then the category is C#. etc.

I am using SQL Comptact. How can I do this? I try a couple of times to no luck. This is the code I got now but this won't work because it will change all pCategory to same value.

@{


var pCategory = "";
var msg = "";




if (IsPost){


 pCategory = Request ["pCategory"];

var SQLINSERT = "INSERT INTO rc_Pages  (pCategory) VALUES (@0) ";
var db = Database.Open("razorc");
db.Execute(SQLINSERT, pCategory);




}


 }














<form method="post">

 @msg

<input type="text" name="pCategory" id="pCategory"/>


 <input type="submit" value="Update"/>

You will need something like:

UPDATE rc_Pages SET pCategory = 'C#' WHERE pName LIKE 'C-Sharp%'
Member Avatar for CriticalError

UPDATE rc_Pages SET pCategory = 'C#' WHERE pName LIKE 'C-Sharp%'

Thanks dude it has worked..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.