background preloader

C#

Facebook Twitter

Using .NET Framework Assemblies in Windows PowerShell - Hey, Scripting Guy! Blog. Summary: Guest bloggers Microsoft PFEs Adam Haynes and Shubert Somer continue their .NET Framework Essentials post by talking about assemblies. Microsoft Scripting Guy, Ed Wilson, is here. Today is part 4 of a 5-part series written by guest blogger Adam Haynes with help from his friend Shubert Somer. You will want to go back and read part 1, part 2, and part 3 (if you have not already done so) before you read today’s blog.

Here’s Adam … Shubert warned me about this “simple” blog post on .NET Framework Essentials. Remember when I said that in order for the script in the previous post to work you needed to have the Active Directory module available/installed? I don’t want you to have to click back and forth between posts, so we are going to continue this post with a new sample to introduce this new concept and reiterate the previous learning. This little snippet pops open the dialog box we are all used to in the GUI when opening a file for input. ~Adam. MSDN - Oracle Sequences. SQL Server and Oracle support the creation of automatically incrementing columns that can be designated as primary keys.

These values are generated by the server as rows are added to a table. In SQL Server, you set the Identity property of a column; in Oracle you create a Sequence. The difference between auto-increment columns in SQL Server and sequences in Oracle is that: In SQL Server, you mark a column as an auto-increment column and SQL Server automatically generates new values for the column when you insert a new row. In Oracle, you create a sequence to generate new values for a column in your table, but there is no direct link between the sequence and the table or column. An Oracle sequence is an object, like a table or a stored procedure.

When you create a sequence in an Oracle database, you can define its initial value and the increment between its values. C# - Object cannot be cast from DBNull to other types. Connecting to an Oracle Database. To create a connection interface, you must add the necessary data entry elements to the design form. With Form1 active, change to design view: from the View menu, select Designer. Alternatively, use the Shift+F7 keyboard shortcut. You may also wish to close the Solution Explorer at this time. Description of the illustration connect09.gifFrom the View menu, select Toolbox. Description of the illustration connect25.gif. Call a function from Oracle in C# Sample Oracle Function ********************** -- Function takes table name as input parameter and returns the record count CREATE OR REPLACE FUNCTION row_count (tab_name CHAR) RETURN INT AS rows INT; BEGIN EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || tab_name INTO rows; RETURN rows; END; // The following is C# program to call the stored procedure function named row_count with one input parameter and gets the returned value DbConn = new OleDbConnection("Provider=MSDAORA;Data Source=<source name>;User ID=<user name>;Password=<pwd>"); // Change infor for user DbConn.Open(); // Open DB DbCommand = new OleDbCommand("row_count",DbConn); // row_count name of stored procedure function DbCommand.CommandType = CommandType.StoredProcedure; // Return value type DbCommand.Parameters.Add(new OleDbParameter("count",System.Data.OleDb.OleDbType .Integer)); DbCommand.Parameters["count"].Direction = ParameterDirection.ReturnValue; // Assign input value DbCommand.Parameters ["query"].Value = dr["DBQuery"];

Asymmetrischer Accessorzugriff (C#-Programmierhandbuch)