Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

i am trying to insert data into sql table using c# ssis script task +very soon +asap

$
0
0
i am trying to insert data into sql table using c# ssis script task .. I am pasting below querry.It is not working I am getting connection issue . any help on this how to insert data. I have question how to write insert script if have a local variable ..please check my querry below. private void InsertIntoTable(string manifest_inBoundfile, string sender, string receiver, string workstream, string manifest_hashid, int manifest_count, string inBouind_hashid, int inBound_count, byte flag) { String inBound_file_name = manifest_inBoundfile; String Sender = sender; String Receiver = receiver; String WorkStream = workstream; String manifest_hash_id = manifest_hashid; String inbound_hash_id = inBouind_hashid; int manifest_row_Count = manifest_count; int inBound_row_Count = inBound_count; DateTime getdate = DateTime.Now; byte Flag = flag; //string strConnectionString = ConnectionStrings["SqlConnectionString"].ConnectionString; //SqlConnection myConnection = new SqlConnection(); //myConnection.ConnectionString = strConnectionString; // string strCommandText = ("INSERT INTO dbo.InBound_File_Audit(" + " AsOfDate, InBound_FileName, Manifest_Sender, Manifest_Reciever, Manifest_Workstream, Manifest_MD5Hash, Manifest_RowCount, InBound_MD5Hash, InBound_FileCount, Validation_Flag" + ") VALUES (" + getdate, inBound_file_name, Sender, Receiver, WorkStream, manifest_hash_id, manifest_row_Count, inbound_hash_id, inBound_row_Count, flag + ")", cn); // SqlCommand cmd = new SqlCommand(strCommandText, myConnection); //SqlConnection cn = new SqlConnection("Data Source=dsqlmerger;initial catalog=dCTLFW; User ID=FHLBDM\\smaganti;Password=Federal01!;Integrated Security=SSPI;"); // //SqlCommand cmd = new SqlCommand("INSERT INTO dbo.InBound_File_Audit(" + " AsOfDate, InBound_FileName, Manifest_Sender, Manifest_Reciever, WorkStream, Manifest_MD5Hash, Manifest_RowCount, InBound_MD5Hash, InBound_FileCount, Validation_Flag" + ") VALUES (" + getdate, inBound_file_name, Sender, Receiver, manifest_hash_id, manifest_row_Count, inbound_hash_id, inBound_row_Count, flag + ")", cn); // cn.Open(); // cmd.ExecuteNonQuery(); // cn.Close(); using (SqlConnection connection = (SqlConnection)(Dts.Connections["ADO.NET Connection"].AcquireConnection(Dts.Transaction) as SqlConnection)) { using (SqlCommand command = connection.CreateCommand()) { string insertString = @" insert into Categories (AsOfDate, InBound_FileName, Manifest_Sender, Manifest_Reciever, Manifest_Workstream, Manifest_MD5Hash, Manifest_RowCount, InBound_MD5Hash, InBound_FileCount, Validation_Flag) values ( getdate, inBound_file_name, Sender, Receiver, WorkStream, manifest_hash_id, manifest_row_Count, inbound_hash_id, inBound_row_Count, Flag )"; command.CommandText = insertString; command.CommandType = CommandType.Text; command.ExecuteNonQuery(); } this.Connections.Connection.ReleaseConnection(connection); } Dts.TaskResult = (int)ScriptResults.Success; throw new NotImplementedException(); }

Viewing all articles
Browse latest Browse all 3145

Trending Articles