Wednesday, December 30, 2020

Submit SQL Server jobs using Webpage C#

If you are running Big jobs in SQL server and big reports from the web page and  the report needs data extraction from complex stored proc, It will mostly be due to large amounts of data ,users can get error, time expires, So if you are giving an interacting report to any user they will not be able to run that report by themselves. In order to resolve this issue you have to run data extraction from behind the scene(in batch mode), so far that what I did, I wrote a stored procedure and created a job in SQL server and executing that SP using that SQL job, using C# code. When the job is done it will send email to the user and the user can run that report by clicking the link in the email. I used following code for that:-


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Reflection;


public partial class DataupDTV : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Label2.Text = "Job Submitted, check your email .....";
        submitjob_corpalloc();
       
    //    SqlConnection myConnection = new SqlConnection(ConnectionString);
    //    string strSQL;
    //    strSQL = "ovDTVdataupd";
    //    SqlCommand cmd = new SqlCommand(strSQL, myConnection);
    //cmd.CommandTimeout = 0;
    //    cmd.CommandType = CommandType.StoredProcedure;
       
    //    myConnection.Open();
    //    cmd.ExecuteNonQuery();
    //    myConnection.Close();

    //    Label2.Text = "Done.....";

    }


    void submitjob_corpalloc()

        {

            SqlConnection DbConn = new SqlConnection(ConnectionString);

            SqlCommand ExecJob = new SqlCommand();

            ExecJob.CommandType = System.Data.CommandType.StoredProcedure;

            ExecJob.CommandText = "msdb.dbo.sp_start_job";

            //zzzzz@zzzzzzz.com Name Status Policy Health State
//SubmitjobSQL Not running



            ExecJob.Parameters.AddWithValue("@job_name", "SubmitjobSQL");
                ExecJob.Connection = DbConn; //assign the connection to the command.

                using (DbConn)

                {

                    DbConn.Open();

                    using (ExecJob)

                    {

                        ExecJob.ExecuteNonQuery();

                    }

                }

            }





    private string ConnectionString
    {
        get
        {
            string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            return connectionString;
        }
    }
   
}

Friday, December 25, 2020

Text to Speech in Any languages

Send Email using SQL Server


--print 'Rajeev.Kumar@MolinaHealthCare.Com' + ';'+  @sndemail + ','

 

set @subj = 'Auto: ' + @processname + ' - Budget Routine Done'

 

SET @tableHTML=

    N'<html><body>'+ 'Hi, ' + '<br>' +

       N'<br>'+

       N'' +  @processname +   ' completed successfully.<br></H4>' +

   N'<H3>Thank You<br>'+

       N'<br></H3></body></html>'

 

exec msdb.dbo.sp_send_cdosysmail

@From = N'Rajeev.Kumar@xxxxxx.Com',

@To = @sndemail,

@cc=N'Rajeev.Kumar@xxxx.Com',

@ReplyTo = N'Rajeev.Kumar@xxxx.Com',

@Subject = @subj,

@Body = @tableHTML,

@BodyType ='HTMLBODY'


Submit SQL server job from webpage in ASP.NET, C#

 Submit SQL server  job from webpage in ASP.NET, C#


void submitjob_corpalloc(string FY)

        {

            SqlConnection DbConn = new SqlConnection(ConnectionString);

            SqlCommand ExecJob = new SqlCommand();

            ExecJob.CommandType = System.Data.CommandType.StoredProcedure;

            ExecJob.CommandText = "msdb.dbo.sp_start_job";


            if (FY == "2020")

            {

                //ExecJob.Parameters.AddWithValue("@job_name", "RunbudgetRoutineMultiYr"); //SP_tblRunEtl_Job

                //ExecJob.Parameters.AddWithValue("@job_name", "RunbudgetRoutineMultiYr"); //sp_etljob_2020

                ExecJob.Parameters.AddWithValue("@job_name", "BudgetRoutine_2020");

                ExecJob.Connection = DbConn; //assign the connection to the command.


                using (DbConn)

                {

                    DbConn.Open();

                    using (ExecJob)

                    {

                        ExecJob.ExecuteNonQuery();

                    }

                }

            }

Convert Your Speech to text using Google Docs

Convert Your Speech to text using Google Docs 

https://www.youtube.com/watch?v=EjADakynNfM




Thursday, November 26, 2020

Refreshable Excel direct connection with SQL Server

Refreshable Excel direct connection with SQL Server

Monday, August 31, 2020

Convert JD Edwards Julian date to calendar date PL SQL

Convert JD Edwards Julian date to calendar date SELECT TO_CHAR(TO_DATE(Y$CKDT+1900000, 'YYDDD'), 'MM/DD/YYYY') as CheckDate, F1.* FROM PRODDTA.F0719 F1

Tuesday, August 18, 2020

Checkbox Click Event Sencha Ext JS

{

                        xtype: 'checkboxfield',

                        boxLabel: 'All Municipal',

                        name: 'AllMunicipal',

                        margin: '0 0 0 0',

                        listeners: {

                              change: function (checkbox, newVal, oldVal) {

                                  if (newVal == '1' && oldVal == '0') {

                                      var allCheckBoxes = checkbox.up('checkboxgroup').items.items;

                                      for (var i = 0; i < allCheckBoxes.length; i++) {

                                          allCheckBoxes[i].setValue('1');

                                      }

                                  }

                              }

                          }

                    }

 

 

https://forum.sencha.com/forum/showthread.php?137463-Checkbox-Click-Event

 



Monday, August 17, 2020

Recordset RecordCount VBA C# .net

Sometime we have to count record set and take decision wheather to show result in excel or not. If count is too much excel can crash. for that people are running same query two times, one time count and another time display record. In order to avoid this run query onece and take decision. like following:- If Recordset.RecordCount > 20000 Then Response = MsgBox(WorksheetFunction.text(Recordset.RecordCount, "_(* #,##0_);_(* (#,##0);_(* ""-""??_);_(@_)") & "Records......Continue?", vbYesNo) If Response = vbNo Then GoTo CleanUp_Exit End If https://docs.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/recordset-recordcount-property-dao

Wednesday, June 10, 2020

Adaptive Insight Data Integration & Connection API

Adaptive Insight Data Integration & Connection API

Web Services API
• Design and implement your own automated integration to Adaptive products
• Access data within your Adaptive application with a lightweight interface
• Adhere to RESTful Web Services principles
• Accepts and returns requests in the form of XML documents

http://cloud-erp.com.au/wp-content/uploads/2014/08/ap_data_integration_screen.pdf



Friday, May 29, 2020

Convert JD Edwards Julian Date to Calendar date in Excel Formula

JD Edwards Julian Date Converter in EXCEL Formulas

Formula to convert a Calendar date to JDE Julian date:
 =CONCAT(YEAR(A1)-1900,RIGHT(CONCAT("000",DAYS(A1,DATE(YEAR(A1),1,1))+1),3))

Formula to convert JD Edwards Julian date to a Calendar date:
=DATE(LEFT(A1,3),1,1)+(RIGHT(A1,3)-1)

Wednesday, May 13, 2020

QTD quarter date from and to

DECLARE @tDate DATETIME
SET @tDate = GETDATE()
 
SELECT @tDate AS 'Input Date',
  DATEADD(q, DATEDIFF(q, 0, @tDate ), 0)
                        AS 'frmDate',      
  DATEADD(d, -1, DATEADD(q, DATEDIFF(q, 0, @tDate ) + 1, 0))
                        AS 'toDate'


Tuesday, May 5, 2020

Get the size of all database in a SQL-Server

    SELECT DB_NAME(database_id) AS DatabaseName,
           sum((size * 8.0) / 1024.0) SizeMB
    FROM sys.master_files
    WHERE DB_NAME(database_id) in(SELECT name FROM sys.databases )
group by DB_NAME(database_id)
order by 1

Monday, February 17, 2020

Godaddy Comma Delimited load CSV file

select  
'Select '+
''''+ cast(SrNo as varchar) +''','''+ StateName+''','''+ cast(TINnumber as varchar) +''','''+ StateCode+''''+' Union '
      from  [dbo].[TblJA_StateCode]