Tuesday, December 11, 2018

MS Access insert data in SQL Server

MS Access insert data in SQL Server 



Option Compare Database

Private Sub Command27_Click()

Call GetDataFromADO

End Sub

Sub GetDataFromADO()
    'Declare variables'
        Set objMyconn = New ADODB.Connection
        Set objMyCmd = New ADODB.Command
        Set objMyRecordset = New ADODB.Recordset
        Dim rc As Long
 'Open Connection'
        objMyconn.ConnectionString = "Provider=SQLOLEDB;Data Source=LAPTOP-0ACTJCP6\SQLEXPRESS;Initial Catalog=sinkydb; Integrated Security=SSPI;"
        objMyconn.Open
        Dim strsql
        strsql = "insert into Tblinserdata(Fname,  Lname, address) select '" & tbfname.Value & "','" & tbLname.Value & "','" & TbAddress.Value & "'"
        Debug.Print strsql
         objMyconn.Execute (strsql)
    'Set and Excecute SQL Command'
        objMyconn.Close
End Sub


Wednesday, December 5, 2018

insert Table range to SQL server Database

Dim rng as Range
Dim defaultDate As string
Dim sql as string, bulkSql as string

Set rng = Range("A1:XX") -- Range of the table. 
defaultDate = Format(Range("A2").Value, "yyyy/mm/dd") 
bulkSql = ""  

'generated sample: insert tRate(ID, Rate, Date) SELECT s.ObjectId, '0.15', '2015/08/24' FROM tSecurity s where s.Number = '007'

For Each row In rng.Rows

    sql= "insert tRate(ID, Rate, Date) SELECT s.ObjectId " & "','" & row.Cells(2).Value & "','" & defaultDate & "' FROM tSecurity s where s.number = '" & row.Cells(1).Value & "'; "

    bulkSql = bulkSql & sql  

Next row

adoCn.Execute bulkSql, , adCmdText

https://stackoverflow.com/questions/32184673/inserting-values-into-sql-server-table-via-vba

Tuesday, November 20, 2018

Close Form In MS Access


        Dim frmName
         frmName  = "YourFormName"
        DoCmd.Close acForm, frmName


Wednesday, October 31, 2018

VLOOKUP Excel

=VLOOKUP(E4,$A$4:$A$20,1,FALSE)


Saturday, October 13, 2018

JD Edwards Fixing IB Batch Using SQL


I got from user not able to post this batch , getting error, so many lines in the batch its difficult to go through each line and fix this.

Informational: Call From : Rajeev Kumar
Contact :
Phone Number :
Tickler Date : 10/11/2018
Subject :
CAUSE . . . . The AA ledger type for 9/23/2018 , document 1283687
is out of balance by 9644.16 .
RESOLUTION. . Verify that each document within this batch is correct.


  So I posted that batch out of balance. after that find out how much is the difference using following SQL :-

Select gldoc,sum(glaa)/100 Amt  from proddta.f0911 where glicu = '1571879' 
group by gldoc
having sum(glaa)<>0

After that found the document number which is out of balance; after that add that amount as following:-

select -917910+661558
and updated total amount(GLAA) in AE doc type as following:-

update proddta.f0911 set glaa=-256352 where glicu = '1571879' and  gldoc in(1283687) and gldct='AE'

after that Run Re-post UBE to fix account Balance.


Thursday, August 30, 2018

Remove Duplicate data from table, SQL Server



SELECT * into #temp2  FROM [vislidb].[dbo].[Employees]
--Create Duplicate data in #temp2
insert into #temp2
SELECT *   FROM [vislidb].[dbo].[Employees] where EmployeeID=1

--Get count , find dups and put in a temp table
SELECT EmployeeID,count(EmployeeID)CountEmployeeID  into #temp3 FROM #temp2
group by EmployeeID
having  count(EmployeeID)>1

--put non dup data  in a temp table using distinct
select distinct * into #temp4 from #temp2 where EmployeeID in(
select EmployeeID from #temp3)

--delete dups from temp table
delete  from #temp2 where EmployeeID in(
select EmployeeID from #temp3)

-- insert from non dup table
insert into #temp2
select * from #temp4

select * from #temp2

Thursday, July 12, 2018

cshtml database connection c# mvc

@using WebMatrix.Data;

@{
    /**/


    ViewBag.Title = "About";
    var db = Database.Open("vislidbConnectionString");
    var selectQueryString = "SELECT * FROM [vislidb].[dbo].[tbl_OrderUserDetails]";


}
<h2>@ViewBag.Title.</h2>
<h3>@ViewBag.Message</h3>


<p>Use this area to provide additional information.</p>
<p>
    this is test1

</p>
<p>
    this is test2

</p>

<p>

    <table>
        <thead>
            <tr>
                <th>Id</th>
                <th>Product</th>
                <th>Description</th>
                <th>Price</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var row in db.Query(selectQueryString))
            {
                <tr>
                    <td>@row.UDUSRID</td>
                    <td>@row.UDPASSWD</td>
                    <td>@row.UDFNAM</td>
                    <td>@row.UDLNAM</td>
                </tr>
            }
        </tbody>
    </table>

</p>

MVC write code C#


@{
var totalMessage = "";
if(IsPost)
    {
    var num1 = Request["text1"];
    var num2 = Request["text2"];
    var total = num1.AsInt() + num2.AsInt();
    totalMessage = "Total = " + total;
}
}











@totalMessage


https://www.w3schools.com/asp/showfile_c.asp?filename=try_razor_cs_004

Saturday, July 7, 2018

Edit Items from SQL Table ASP.NET C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

public partial class userListEdit : System.Web.UI.Page
{
    Int32 countRec;

    protected void Page_Load(object sender, EventArgs e)
    {
       

        if (!IsPostBack)
        {
            Button8.Visible = false;
            Button9.Visible = false;
            Label11116.Visible = false;
            Button5.Visible = true;
            Button6.Visible = true;
            Button7.Visible = true;

            if (Request["type"]== "E")
            {
                UserListloaddata();
            }
            else
            {
                Label11113.Visible = false;
                TBId.Visible = false;
                Button7.Visible = false;
                Button10.Visible = false;
            }
        }
    }

    void UserListloaddata()
    {
        string strSQL;
        SqlConnection myConnection = new SqlConnection(ConnectionString);
         strSQL = "select * FROM tblMM_User_List WHERE MM_ID=" + Request["ID"];
        SqlCommand cmd = new SqlCommand(strSQL, myConnection);
        myConnection.Open();
        SqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
        while (myReader.Read())
        {
            TBId.Text = myReader["MM_ID"].ToString();
            TBUserId.Text = myReader["MM_UserID"].ToString();
            TBUserFnam.Text = myReader["MM_User_First"].ToString();
            TBUserLname.Text = myReader["MM_User_Last"].ToString();
            TBSecode.Text = myReader["MM_Sec_Code"].ToString();
            DDTBSecTyp.SelectedItem.Text = myReader["MM_Type"].ToString();
            TBTicNo.Text = myReader["MM_TicketNo"].ToString();
            TBTicDT.Text = myReader["MM_TicketDate"].ToString();
            TBDtSubmit.Text = myReader["MM_DtSubmtLegal"].ToString();
            TBDateLegal.Text = myReader["MM_DtAddLegal"].ToString();
            TBComm.Text = myReader["MM_Comment"].ToString();
        }
        myReader.Close();
        myConnection.Close();
    }



    void updateMemo()
    {


        //Response.Write(DDTBSecTyp.SelectedItem.Text);
        //Response.End();
        SqlConnection myConnection = new SqlConnection(ConnectionString);
        string strSQL;
        strSQL = "update tblMM_User_List set MM_UserID=@MM_UserID,MM_User_First=@MM_User_First,MM_User_Last=@MM_User_Last,MM_Sec_Code=@MM_Sec_Code,MM_Type=@MM_Type,MM_TicketNo=@MM_TicketNo,"
        + "MM_TicketDate=@MM_TicketDate,MM_DtSubmtLegal=@MM_DtSubmtLegal,MM_DtAddLegal=@MM_DtAddLegal,MM_Comment=@MM_Comment,MM_UpdDate=@MM_UpdDate"
        + " WHERE MM_Id =" + Request["ID"];
            SqlCommand cmd = new SqlCommand(strSQL, myConnection);
            cmd.Parameters.AddWithValue("@MM_UserID" , TBUserId.Text);
            cmd.Parameters.AddWithValue("@MM_User_First", TBUserFnam.Text);
            cmd.Parameters.AddWithValue("@MM_User_Last",TBUserLname.Text);
            cmd.Parameters.AddWithValue("@MM_Sec_Code", TBSecode.Text);
            cmd.Parameters.AddWithValue("@MM_Type", DDTBSecTyp.SelectedItem.Text);
            cmd.Parameters.AddWithValue("@MM_TicketNo",TBTicNo.Text);
            cmd.Parameters.AddWithValue("@MM_TicketDate",TBTicDT.Text);
            cmd.Parameters.AddWithValue("@MM_DtSubmtLegal",TBDtSubmit.Text) ;
            cmd.Parameters.AddWithValue("@MM_DtAddLegal",TBDateLegal.Text);
            cmd.Parameters.AddWithValue("@MM_Comment",TBComm.Text);
            cmd.Parameters.AddWithValue("@MM_UpdDate", DateTime.Today.ToShortDateString());
        myConnection.Open();
        cmd.ExecuteNonQuery();
        myConnection.Close();
    }

    void insertUserlist()
    {
        //Response.Write(DDTBSecTyp.SelectedItem.Text);
        //Response.End();


        SqlConnection myConnection = new SqlConnection(ConnectionString);
        string strSQL;
        strSQL = "insert into tblMM_User_List(MM_UserID,MM_User_First,MM_User_Last,MM_Sec_Code,MM_Type,MM_TicketNo,MM_TicketDate,MM_DtSubmtLegal,MM_DtAddLegal,MM_Comment,MM_UpdDate)values"
        + "(@MM_UserID,@MM_User_First,@MM_User_Last,@MM_Sec_Code,@MM_Type,@MM_TicketNo,@MM_TicketDate,@MM_DtSubmtLegal,@MM_DtAddLegal,@MM_Comment,@MM_UpdDate)";
        SqlCommand cmd = new SqlCommand(strSQL, myConnection);
        cmd.CommandType = CommandType.Text;
        cmd.Parameters.AddWithValue("@MM_UserID", TBUserId.Text);
        cmd.Parameters.AddWithValue("@MM_User_First", TBUserFnam.Text);
        cmd.Parameters.AddWithValue("@MM_User_Last", TBUserLname.Text);
        cmd.Parameters.AddWithValue("@MM_Sec_Code", TBSecode.Text);
        cmd.Parameters.AddWithValue("@MM_Type", DDTBSecTyp.SelectedItem.Text);
        cmd.Parameters.AddWithValue("@MM_TicketNo", TBTicNo.Text);
        cmd.Parameters.AddWithValue("@MM_TicketDate", TBTicDT.Text);
        cmd.Parameters.AddWithValue("@MM_DtSubmtLegal", TBDtSubmit.Text);
        cmd.Parameters.AddWithValue("@MM_DtAddLegal", TBDateLegal.Text);
        cmd.Parameters.AddWithValue("@MM_Comment", TBComm.Text);
        cmd.Parameters.AddWithValue("@MM_UpdDate", DateTime.Today.ToShortDateString());
        myConnection.Open();
        cmd.ExecuteNonQuery();
        myConnection.Close();
    }


      protected void Button5_Click(object sender, EventArgs e)
      {
          if (Request["type"].ToString() == "E")
          {
              updateMemo();
              updateusersercurity();
              Response.Redirect("userListM.aspx");
          }
          if (Request["type"].ToString() == "A")
          {
              if (countRec >= 1)
              {
                  Label11117.Visible = true;
              }
              else
              {
                  Countdupdata();
                  insertUserlist();
                  updateusersercurity();
                  Response.Redirect("userListM.aspx");
              }
          }
      }

      void Deletedata()
      {
          SqlConnection myConnection = new SqlConnection(ConnectionString);
          string strSQL;
          strSQL = "delete from tblMM_User_List WHERE MM_ID=" + Request["ID"];
          SqlCommand cmd = new SqlCommand(strSQL, myConnection);
          cmd.CommandType = CommandType.Text;
          myConnection.Open();
          cmd.ExecuteNonQuery();
          myConnection.Close();
         
      }


      void Countdupdata()
      {
          SqlConnection myConnection = new SqlConnection(ConnectionString);
          string strSQL;
          strSQL = "SELECT COUNT(*) FROM tblMM_User_List where  MM_UserID ='" + TBUserId.Text +  "' and  MM_Sec_Code='" + TBSecode.Text + "'";
          myConnection.Open();
          SqlCommand comm = new SqlCommand(strSQL, myConnection);
          countRec = (Int32)comm.ExecuteScalar();
          myConnection.Close();
      }


      protected void Button6_Click(object sender, EventArgs e)
      {
          Response.Redirect("userListM.aspx");
      }

      protected void Button8_Click(object sender, EventArgs e)
      {
          Deletedata();
          updateusersercurity();
          Response.Redirect("userListM.aspx");
      }
      protected void Button9_Click(object sender, EventArgs e)
      {
          Button8.Visible = false;
          Button9.Visible = false;
          Button10.Visible = false;
          Label11116.Visible = false;
          Button5.Visible = true;
          Button6.Visible = true;
          Button7.Visible = true;

      }
      protected void Button7_Click(object sender, EventArgs e)
      {
          Button8.Visible = true;
          Button9.Visible = true;
          Label11116.Visible = true;
          Button10.Visible = false;
          Button5.Visible = false;
          Button6.Visible = false;
          Button7.Visible = false;
      }
      protected void Button10_Click(object sender, EventArgs e)
      {
          Countdupdata();
          if (countRec >= 1)
          {
              Label11117.Visible = true;
          }
          else
          {
              insertUserlist();
              updateusersercurity();
              Response.Redirect("userListM.aspx");
          }

         
      }

      void updateusersercurity()
      {
          SqlConnection myConnection = new SqlConnection(ConnectionString);
          string strSQL;
          strSQL = "dbo.SP_MM_SecurityByUser '" + TBUserId.Text.Trim() + "'";
          SqlCommand cmd = new SqlCommand(strSQL, myConnection);
          cmd.CommandType = CommandType.Text;
          myConnection.Open();
          cmd.ExecuteNonQuery();
          myConnection.Close();
          Label11112.Visible = true;
      }


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

}





--------------

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="userListEdit.aspx.cs" Inherits="userListEdit" %>


 

       

           
               
                                            Text="User List Add/Modification ">
               
           
           
               
                   
           
           
               
                   
               
               
                   
               
           
           
               
                   
               
               
                   
               
           
           
               
                   
               
               
                   
               
           

               
                   
               
               
                   
               
           
           
               
                   
               
               
                   
                    -
                    CO
                    BU

                   
               
           

               
                   
               
               
                   
               
           

               
                   
               
               
                   
               
           

               
                   
               
               
                   
               
           

               
                                            Font-Bold="True">
               
               
                   
               
           

               
                                            Font-Bold="True">
               
               
                   
               
           

               
                   
               
               
                                            Width="234px">
               
           


               
                   
               
                   
                   
                   
                   
                                            Text="Duplicate Record !!!" Visible="False">
               
           


               
                   
               
                                            Text="Are Yor Sure?   ">
  
                   

               
           

       
 
   
   
   
   
   
   








Thursday, June 28, 2018

JDE Sales Module Order to Cash and main tables

https://docs.google.com/presentation/d/1fI4yFMBgRwbvmvMBYzyhVY1jUIAjvduNh-s2F235h6s/edit?usp=sharing

Wednesday, June 27, 2018

JD Edwards Main Application and Process For Interview

JD Edwards Main Tables and Program By Modules
- Sales Order Processing
Tables
F4201 - Sales Order Header
F4211-  Sales Order Details
Application
P4210 - Sales order Entry Application
P4205 Shipment Confirmation
UBE
R42520 Print Pickslip
R42565 Print Invoices
R42800 Sales Update

Activity Rules



- Purchase order module
F4301 - Purchase Order Header
F4311-  Purchase Order Details
Application
P4310 - Purchase order Entry Application
R43500 -Print PO
Activity Rules




Monday, June 11, 2018

Inventory Adjustment JD Edwards

Use following :-
P47120 
R47121
F47121

Monday, June 4, 2018

Find Duplicate Value in Array C# Asp.net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int[] test = { 3, 6, 8, 10, 2, 3 ,6 };
        int count = 0;
       // Random ranDuplicateChange;
        for (int i = 0; i < test.Length; i++)
        {
            count = 0;
         //   Console.WriteLine(" {0} :: The current number is: {1} ", i, test[i]);
            for (int j = 0; j < test.Length; j++)
            {
                if (test[i] == test[j])
                {
                    count++;
                    if (count >= 2)
                    {
                        Response.Write ("Duplicate found: {0}"+ test[j] +"<BR>");
                       
                    }
                }
            }
        }

    }



}