executing sql query from inline C#

Home Page Forums BizTalk 2004 – BizTalk 2010 executing sql query from inline C#

Viewing 1 reply thread
  • Author
    Posts
    • #23577

      HI,

         I would like a simple select to retrieve a value from oracle database through inlineC#.

      what should be the connection string. Any fragment of code is much appreciated.

       

      Thank you

      Sangeetha

    • #23587

      Write a helper dll and you can access it from the command shape in your orchestration.

      • #23611

        You can create a method with the following. But this is for SQL server database. You need to change the interfaces for oracle database

         

        //Write the Query

        string sqlQuery = “SELECT * FROM table WHERE condition”;

        string connectionString = Common.GetAppSetting(SERVER_CONNECTION);

        //connect to database

        SqlConnection connection = new SqlConnection(connectionString);

         

        //run the SQL query

        SqlCommand sqlComm = new SqlCommand(sqlQuery, connection);

        SqlParameter myParam = new SqlParameter();

        myParam.ParameterName = “@mydate”;

        myParam.Value = DateTime;

        sqlComm.Parameters.Add(myParam);

        sqlComm.Connection.Open();

        ArrayList recordList = new ArrayList();

        SqlDataReader reader = sqlComm.ExecuteReader();

        // add data to Array List

        while (reader.Read())

        {

        object[] values = new object[reader.FieldCount];

        reader.GetValues(values);

        Employee employee = new Employee();

        employee.EmployeeID = values[0].ToString();

        employee.Guid = Guid.NewGuid().ToString();

        recordList.Add(employee);

        }

        sqlComm.Connection.Close();

        return recordList;

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.