Hi Guys,
I need your help as in yesterday this deadline was last week already but I'm still struggling.
I want to ask if its possible to have an insert statement with select statements?exam ple I want to insert dataExtracted, dateFrom, dateTo,image but the dateFrom and dateTo is in another query how do I pass them to the insert statement :-(
this is what I have:
string query1 = @"select DATEADD(d,+1,DA TEADD(mm, DATEDIFF(m,0,GE TDATE())-6,-1)) as DateFrom
from dbo.tbl_sale_da te";
string query2 = @"select DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GE TDATE())+1,0)) as DateTo
from dbo.tbl_sale_da te";
ConnectionStrin g = Properties.Sett ings.Default.Co nnectionString;
SqlConnection con = new SqlConnection(C onnectionString );
{
string path = @"C:\\DownLoade dFile.zip";
byte[] bytearr = File.ReadAllByt es(path);
SqlCommand cmd = new SqlCommand("pro cInsertToBlobDa ta", con);
cmd.CommandType = CommandType.Sto redProcedure;
cmd.Parameters. Add(new SqlParameter("@ DateExtracted", DateTime.Now));
cmd.Parameters. Add(new SqlParameter("@ DateFrom", SqlDbType.DateT ime));
cmd.Parameters. Add(new SqlParameter("@ DateTo", SqlDbType.DateT ime));
cmd.Parameters. Add(new SqlParameter("@ Data", bytearr));
cmd.Parameters. Add(new SqlParameter("@ DBParentCategor yKey", SqlDbType.DateT ime));
}
I need your help as in yesterday this deadline was last week already but I'm still struggling.
I want to ask if its possible to have an insert statement with select statements?exam ple I want to insert dataExtracted, dateFrom, dateTo,image but the dateFrom and dateTo is in another query how do I pass them to the insert statement :-(
this is what I have:
string query1 = @"select DATEADD(d,+1,DA TEADD(mm, DATEDIFF(m,0,GE TDATE())-6,-1)) as DateFrom
from dbo.tbl_sale_da te";
string query2 = @"select DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GE TDATE())+1,0)) as DateTo
from dbo.tbl_sale_da te";
ConnectionStrin g = Properties.Sett ings.Default.Co nnectionString;
SqlConnection con = new SqlConnection(C onnectionString );
{
string path = @"C:\\DownLoade dFile.zip";
byte[] bytearr = File.ReadAllByt es(path);
SqlCommand cmd = new SqlCommand("pro cInsertToBlobDa ta", con);
cmd.CommandType = CommandType.Sto redProcedure;
cmd.Parameters. Add(new SqlParameter("@ DateExtracted", DateTime.Now));
cmd.Parameters. Add(new SqlParameter("@ DateFrom", SqlDbType.DateT ime));
cmd.Parameters. Add(new SqlParameter("@ DateTo", SqlDbType.DateT ime));
cmd.Parameters. Add(new SqlParameter("@ Data", bytearr));
cmd.Parameters. Add(new SqlParameter("@ DBParentCategor yKey", SqlDbType.DateT ime));
}
Comment