simple Data_manipulate question

Joined
Oct 24, 2009
Messages
3
Reaction score
0
hello

i have a field in my database wich name is "DownloadCount".

i want to write code wich add "1" to "DownloadCount" after every click on list view on "filename", so i wrote this store procedure:


ALTER PROCEDURE [dbo].[DownloadCount_SP]
@FileCodesql int
AS BEGIN
update [File]
set DownloadCount=DownloadCount+1
Where FileCode = @FileCodesql
END


and this Class.method


public void InsertDownloadCount(string FileCodeapp){
SqlConnection Cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Cs_FileServer"].ConnectionString);
SqlCommand InsertNewItem = new SqlCommand("DownloadCount_SP", Cn);
InsertNewItem.CommandType = CommandType.StoredProcedure;
InsertNewItem.Parameters.Add("FileCodesql", SqlDbType.Int).Value =int.Parse(FileCodeapp);
Cn.Open();
InsertNewItem.ExecuteNonQuery();
InsertNewItem.Dispose();
Cn.Close();
}

and this behind code"



protected void GridView_Cat_SelectedIndexChanged(object sender, EventArgs e){


Data_Manipulate OInsertDownloadCount = new Data_Manipulate();



OInsertDownloadCount.InsertDownloadCount(GridView_Cat.SelectedValue.ToString());

}



now there isn ot any error message but it does not work, i think there is an error in:


InsertNewItem.ExecuteNonQuery();

or in my casting type int to string or string to int

could you please help me?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top