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?
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?