私がしていることについての少しの背景。このコードに移動するクリック呼び出しがあるボタンがあります。
static public DataSet shareFiles(TransitoryRegObj argTransRegObj)
{
string sqlString = "do_share_files"; // it's a stored procedure
SqlConnection cnn = new SqlConnection(masterConn);
SqlCommand comm = new SqlCommand(sqlString, cnn);
DataSet ds = new DataSet();
try
{
cnn.Open();
SqlCommand Comm = new SqlCommand(sqlString, cnn);
Comm.CommandType = CommandType.StoredProcedure;
comm.Dispose();
cnn.Close();
return ds;
}
catch (Exception ex)
{
// log here should anything go wrong with anything
// lblmessage.Text = "Error: " + ex.Message;
if (comm != null)
comm.Dispose();
if (cnn != null)
cnn.Close();
DataTable dt = new DataTable("ExceptionTable");
dt.Columns.Add("ExceptionMessage");
dt.Rows.Add(ex.Message);
ds = new DataSet();
ds.Tables.Add(dt);
return ds;
}
}
コードは正常に実行されますが、データベースには何も書き込まれません。これがdo_share_filesストアドプロシージャです。
ALTER PROCEDURE [dbo].[do_share_files]
--@device_id bigint, @user_id bigint, @file_name varchar(50),@full_up_path varchar(50), @upLength varchar(30)
--,@mime_type varchar(20), @filedate varchar(30)
AS
BEGIN
insert into [user_files] (device_id, user_id, original_name, original_path, up_path, content_type, up_dt)
values (17, 30, 'test.pg', 'test.pg', 'test.pg','test.pg', '2012-11-15 03:58:06.043')
END
ストアドプロシージャで実行しようとしているだけなので、今のところ静的な値があります。私はasp.netを初めて使用し、何が間違っているのかわかりません。どんな助けでもいただければ幸いです。
ありがとう!