Pages

Friday, May 9, 2014

Basic knowledge about the Integration of Salesforce API via C#.Net

The best start-up link for the Integration of Salesforce API via C#.Net is here:

On this page you can learn about benefits of Integrating the Force.com Platform with Microsoft .NET as well as how you can consume this API on your .Net platform step by step.

After familiar with the basic steps of Integration you can do some very essential code, here are the links for that:

For the creation of a record in a Salesforce Object (assume that you have some basic knowledge of SFDC) via C#:

For the executing a query against the specified objects and returns data that matches the specified criteria:


Hopefully this will help a lot!, although if you have any problem to work with these, let me know via your comment. Thanks for reading this blog.

Thursday, October 27, 2011

How to insert and retrieve datetime data type field in MS SQL Server 05 as ‘dd/mm/yyyy’ date format:





--Create a table in MS SQl server for the demo:
create table test_date
(
--Creating a auto increment column for primary key:
test_id bigint identity(1,1) not null primary key,

--Now creating a column which holds the date values form the input:
holiday datetime

)
--Provide input to the created table in ‘dd/mm/yyyy’ date format:
insert into test_date values(convert(datetime,'28/10/2011',103))

--Select inserted date value in required ‘dd/mm/yyyy’ date format:
select convert(varchar,holiday,103) as [Date in dd/mm/yyy format ] from test_date


You can also perform various operations on date format with the help of following link:









Sunday, March 27, 2011

Example of Escape Sequence in C#.Net:

Here is illustration program, you can find the result by run it !




using System;


namespace tryNew
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("this is use of single quotation mark " + "\'in quotation\'");
            Console.Write("\n");
            Console.Write("this is use of double quotation mark " + "\"in quotation\"");
            Console.Write("\n");
            Console.Write("this is use of Backslash " + "\\ with backslash");
            Console.Write("\n");
            Console.Write("this is use of Backspace " + "---\b with backspace");
            Console.Write("\n");
            Console.Write("this is use of From feed " + "\f with From feed");
            Console.Write("\n");
            Console.Write("this is use of Tab charracter " + "\t with Tab charracter");

            Console.Write("\n");
            string mywords = @"'this is the example which shows that how to avoid escape sequences'";
            Console.Write("this is use of @ to avoid escape sequences  " + mywords);
            Console.Write("\n");
            Console.Write("press Enter to exit");
            Console.Read();


        }
    }
}

Example of multiple Main() methods in C#.Net:


C# Syntax:


using System;
namespace m1
{

    class c1
    {
        public static void Main()
        {
            Console.WriteLine("this is from the class 1 of the namespace 1");
            Console.ReadLine();

        }
    }
    class c2
    {
        public static void Main()
        {
            Console.WriteLine("this is from the class 2 of the namespace 2");
            Console.ReadLine();

        }
    }

}



How to run in console:


C:\>csc manyMain.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.21022.8
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.

manyMain.cs(16,20): error CS0017: Program 'c:\manyMain.exe' has more than one
        entry point defined: 'm1.c1.c2.Main()'.  Compile with /main to specify
        the type that contains the entry point.
manyMain.cs(7,20): error CS0017: Program 'c:\manyMain.exe' has more than one
        entry point defined: 'm1.c1.Main()'.  Compile with /main to specify the
        type that contains the entry point.

C:\>csc manyMain.cs /main:m1.c1
Microsoft (R) Visual C# 2008 Compiler version 3.5.21022.8
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.


C:\>manyMain
this is from the class 1 of the namespace 1



Friday, June 5, 2009

Interaction with Oracle through C#.NET


Create user in oracle 9i


step-1:
login in oracle as sysdba

step-2:
type the following syntax in oracle console:
create user username(your user name) identified by password(your password)

step-3:
Grant control to new created user with the help of following command :
grant connect,resource to username(your user name)

step-4:
Connect the oracle with your new created user with user name and corresponding password

Now you are connect with oracle with your user name and password.

Let us do some new thing


How to connect with oracle with the c#.net:

Step 1: use this namespace “using System.Data.OracleClient;” .

Step2: make the connection with oracle by using “OracleConnection con = new OracleConnection("Uid=username;Pwd=password;Server=oracleSID");”.

Step3: make an object of oraclecommand with “OracleCommand cmd1;” and for oracledatareader object “OracleDataReader dr;”.
Step4: write the oracle query as “string query=”select sysdate from dual”;”
Step5: put this query in the command object as “cmd1 = new OracleCommand(query, con);”
Step6: open the connection object with “con.Open();”.
Step7: run the command with “dr = cmd1.ExecuteReader();”
Step8: retrive the data with “while (dr.Read()) {   string a = dr[0].ToString();  }”.
Step9: close the connection with “con.Close();”.

The final systax would be:

using System;
using System.Data;
using System.Data.OracleClient;
using System.Windows.Forms;

namespace connection
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

OracleConnection con = new OracleConnection("Uid=username;Pwd=password;Server=oracleSID");

        private void Form2_Load(object sender, EventArgs e)
        {
            connectOracle();
        }

        private void connectOracle()
        {
            OracleCommand cmd;
            OracleDataReader dr;
            string output = "";
            string query = "select sysdate from dual";
            try
            {

                cmd = new OracleCommand(query, con);
                con.Open();
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    output = dr[0].ToString();
                }
               
            }
            catch (OracleException oex)
            {
                string error = oex.ToString();
            }
            finally
            {
                con.Close();
            }
        }
    }
}




Note: this is for educational purpuse only and use it at your risk