Sunday, May 13, 2018

Constructors in VB.NET

A constructor in VB.NET is defined as a procedure that has the name New (rather than Initialize as in VB 6.0) and can accept arguments to allow clients to pass data into the instance to assist with initialization. Constructors do not return values and therefore are always declared as a Sub.Mar 1, 2002


Thursday, May 10, 2018

Divide by Sum SQL Server same table join

Divide by Sum SQL Server same table join

select a.objsub,a.bu, a.period_01a, a.period_01a/sum(b.period_01a),sum(b.period_01a)FROM FORECAST_DATA a
left outer join FORECAST_DATA b on a.bu=b.bu  and  b.objsub like '9991%'
where left(a.objsub,2) in ('41','53','54','55','56')
--and a.bu='021000'
group by a.objsub, a.period_01a,a.bu


having sum(b.period_01a)<>0

Parameter by Value and reference


C# program that demonstrates parameter passing

using System;

class Program
{
    static void Main()
    {
        int val = 0;

        Example1(val);
        Console.WriteLine(val); // Still 0.

        Example2(ref val);
        Console.WriteLine(val); // Now 2.

        Example3(out val);
        Console.WriteLine(val); // Now 3.
    }

    static void Example1(int value)
    {
        value = 1;
    }

    static void Example2(ref int value)
    {
        value = 2;
    }

    static void Example3(out int value)
    {
        value = 3;
    }
}

Output

0
2
3

 
Notes, Example 1. Example1 uses value-passing semantics for its declaration. Therefore, when it changes the value of its parameter int, that only affects the local state of the method.
Notes, Example 2. Example2 uses the ref modifier for its int parameter. This informs the compiler that a reference to the actual variable (int val) is to be passed to Example2.
Note:
The ref keyword is used in the calling syntax in Main. When Example2 sets its parameter to 2, this is reflected in the Main method.

Notes, Example 3. Example3 uses out on its parameter. This has compile-time checking features. These involve definite assignment rules.
Finally:
Example3 sets its parameter to 3—this is reflected in the calling location.

Ref, out. What is the difference between ref and out? The difference is in the compiler's application of the definite assignment analysis step.
Important:
The compiler demands that an out parameter be "definitely assigned" before any exit. There is no such restriction with the ref.

Saturday, May 5, 2018

Temporary table in PL/SQL, kind of Select into

 create global temporary table temp_raj 
 on commit preserve rows 
 as 
 select * from raj.sal where 1=0 

 insert into temp_raj select * from raj.sal; 

Saturday, March 10, 2018

Insert C# SQL/Connection String

string strSQL1;
            strSQL1 = "   insert into [tblcontrol_Comt] ( [SLNO],[Status],[Reason]) select " + t1 + ",'" + DropDownList4.SelectedItem + "','" + TB_Comment.Text + "'";
            strSQL = strSQL + strSQL1;

            //Response.Write(strSQL);
            //Response.End();


            SqlCommand cmd = new SqlCommand(strSQL, myConnection);
            cmd.CommandTimeout = 30000;
            cmd.CommandType = CommandType.Text;
            myConnection.Open();
            cmd.ExecuteNonQuery();
            myConnection.Close();


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


On Sat, Mar 10, 2018 at 10:42 PM, Rajeev Kumar <rajeevkum@gmail.com> wrote:
 string strSQL1;
            strSQL1 = "   insert into [tblcontrol_Comt] ( [SLNO],[Status],[Reason]) select " + t1 + ",'" + DropDownList4.SelectedItem + "','" + TB_Comment.Text + "'";
            strSQL = strSQL + strSQL1;

            //Response.Write(strSQL);
            //Response.End();


            SqlCommand cmd = new SqlCommand(strSQL, myConnection);
            cmd.CommandTimeout = 30000;
            cmd.CommandType = CommandType.Text;
            myConnection.Open();
            cmd.ExecuteNonQuery();
            myConnection.Close();



--
Rajeev Kumar
949-378-6094

insert C# SQL

 string strSQL1;
            strSQL1 = "   insert into [tblcontrol_Comt] ( [SLNO],[Status],[Reason]) select " + t1 + ",'" + DropDownList4.SelectedItem + "','" + TB_Comment.Text + "'";
            strSQL = strSQL + strSQL1;

            //Response.Write(strSQL);
            //Response.End();


            SqlCommand cmd = new SqlCommand(strSQL, myConnection);
            cmd.CommandTimeout = 30000;
            cmd.CommandType = CommandType.Text;
            myConnection.Open();
            cmd.ExecuteNonQuery();
            myConnection.Close();

Wednesday, November 22, 2017

Load Excel Name Range Data to SQL Server table, VBA


Sub ShowRecordCount()
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
With cn
    .Provider = "Microsoft.ACE.OLEDB.12.0"
    .ConnectionString = "Data Source=C:\temp\JW_E&PM_041.xlsx;" & _
"Extended Properties=Excel 12.0;"
    .Open
End With

sSQL = "SELECT * FROM rngloaddata"

Set oRs = New ADODB.Recordset
oRs.Open sSQL, cn, adOpenStatic, adLockBatchOptimistic, adCmdText

Set cn2 = CreateObject("ADODB.Connection")
    With cn2
        .CursorLocation = adUseClient
        .Open "Driver={SQL Server};Server=Server01; Database=budget; UID=DB; PWD=xxxxxx"
        .CommandTimeout = 0
        oRs.MoveFirst
       
   
   
    For i = 0 To Range("rngloaddata").Columns.Count - 1
        strcolnmName = strcolnmName & ", CAST('' AS VARCHAR(255))" & oRs.Fields(i).Name
       
    Next
   
    tablstr = "IF OBJECT_ID('tempdb..##temp1345') IS NOT NULL  drop table ##temp1345     select  " & Right(strcolnmName, Len(strcolnmName) - 1) & " into ##temp1345"
    Debug.Print tablstr
    .Execute tablstr
    Debug.Print tablstr
   
    Do While Not oRs.EOF
    strcolnmValue = ""
            For i = 0 To Range("rngloaddata").Columns.Count - 1
                strcolnmValue = strcolnmValue & ",'" & oRs.Fields(i) & "'"
            Next
       
        .Execute "INSERT INTO ##temp1345 select " & Right(strcolnmValue, Len(strcolnmValue) - 1)
           
            oRs.MoveNext
            Loop
    End With

cn.Close
End Sub

Tuesday, November 21, 2017

Insert Data Using Named range in SQL server table Excel VBA

Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
With cn
    .Provider = "Microsoft.ACE.OLEDB.12.0"
    .ConnectionString = "Data Source=C:\temp\JW_E&PM_041.xlsx;" & _
"Extended Properties=Excel 12.0;"
    .Open
End With

sSQL = "SELECT * FROM testrangdata"
'sSQL = "SELECT * FROM [Sheet1$A1:E46]"
Set oRs = New ADODB.Recordset
oRs.Open sSQL, cn, adOpenStatic, adLockBatchOptimistic, adCmdText

Set cn2 = CreateObject("ADODB.Connection")
    With cn2
        .CursorLocation = adUseClient
        .Open "Driver={SQL Server};Server=Server1\SQL1; Database=mydb; UID=bbbbb; PWD=MMMMM"
        .CommandTimeout = 0
        oRs.MoveFirst
        Do While Not oRs.EOF
        Debug.Print oRs.Fields(1)
     
            .Execute "INSERT INTO budget.dbo.delthisTEMP_TABLE ( [BU] ) VALUES ('" & oRs.Fields(1) & "')"
            oRs.MoveNext
            Loop
    End With

cn.Close

XLSX excel vba connectionstring

Sub test()

Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=C:\temp\JW_E&PM_04.xlsx;" & _
"Extended Properties=Excel 8.0;"
.Open
End With
End Sub


Sub ShowRecordCount()
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
With cn
    .Provider = "Microsoft.ACE.OLEDB.12.0"
    .ConnectionString = "Data Source=C:\temp\JW_E&PM_04.xlsx;" & _
"Extended Properties=Excel 12.0;"
    .Open
End With

sSQL = "SELECT * FROM [sheet1$]"
Set oRs = New ADODB.Recordset
oRs.Open sSQL, cn, adOpenStatic, _
               adLockBatchOptimistic, adCmdText
MsgBox oRs.RecordCount
cn.Close
End Sub


read named range in VBA


Sub ShowRecordCount()
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
With cn
    .Provider = "Microsoft.ACE.OLEDB.12.0"
    .ConnectionString = "Data Source=C:\temp\JW_E&PM_04.xlsx;" & _
"Extended Properties=Excel 12.0;"
    .Open
End With

sSQL = "SELECT * FROM testrange"
'sSQL = "SELECT * FROM [Sheet1$A1:E46]"
Set oRs = New ADODB.Recordset
oRs.Open sSQL, cn, adOpenStatic, _
               adLockBatchOptimistic, adCmdText
MsgBox oRs.RecordCount
cn.Close
End Sub

Thursday, November 2, 2017

Convert Amount into currency with $ sign and commas using jquery/javascript

currentamount.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")

Wednesday, October 25, 2017

JD Edwards - Pass Value to UBE/Application in URL

Topic related to this:-
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=371210426635792&id=748331.1&_afrWindowMode=0&_adf.ctrl-state=ydq9vvmc_4




How to create and get access of JD Edwards application
http://oooooo.sssssss.com/jde/E1Menu.maf?OID=P0011_W0011A&User=rajeev&Password=xxxxxx&Environment=p&FormDSTmpl=|2|&FormDSData=|99999|&selectJPD910=*ALL

http://oracle.SSSSSSSS.com/jde/E1Menu.maf?OID=P0011_W0011_ZJDE0001A&FormDSTmpl=|1|&FormDSData=|G|




Sunday, October 22, 2017

Create Excel Office addin using C# – Part 1 (Ribbon Designer)



https://sandeepfabiani.wordpress.com/2013/08/24/create-excel-office-addin-using-csharp-ribbon-designer/