Saturday, April 29, 2006

Running NUnit in SharpDevelop

Download the most recent version of NUnit. Use the Windows version.

By default it installs in Program Files/NUnit* . Add the NUnit.Framework.dll to a new C# class library.


The following then runs.

/*
* Created by SharpDevelop.
* User: Administrator
* Date: 4/29/2006
* Time: 9:48 PM
*
* To change this template use Tools Options Coding Edit Standard Headers.
*/
using System;
using NUnit.Framework;
namespace NUnitFoo
{
[TestFixture]
public class MyTest
{
[Test]
public void Test1()
{
Assert.Fail("This fails.");
}
}
}

Friday, April 28, 2006

Meaning of column not allowed error

http://ora-00984.ora-code.com/

ORA-00984:column not allowed here
Cause:A column name was used in an expression where it is not permitted, such as in the VALUES clause of an INSERT statement.
Action:Check the syntax of the statement and use column names only where appropriate.

Wednesday, April 26, 2006

How to use ODBC to run an Oracle Stored Procedure in VB.NET

cn = New OdbcConnection("DRIVER={Oracle in OraHome81};SERVER=yourserver;UID=yourid;" _
& "PWD=yourpassword;DBQ=yourserver;")

'Procedure being tested. Input parameters unit number, event id, result date, medcin id list
Dim myRunSP As String = "CALL acpg_v1_pkg.process_event_medcin_ids()"
cmd = New OdbcCommand
cmd.CommandType() = CommandType.StoredProcedure
cmd.CommandText = myRunSP
cmd.Parameters.Add(New OdbcParameter("p_Unit_Number", OdbcType.Numeric)).Value = 90909090
cmd.Parameters.Add(New OdbcParameter("p_Event_Id", OdbcType.Numeric)).Value = 1
cmd.Parameters.Add(New OdbcParameter("p_result_ncid_list", OdbcType.VarChar)).Value = 1
cmd.Parameters.Add(New OdbcParameter("p_result_date", OdbcType.Date)).Value = Now

cn.Open()
cmd.Connection = cn
cmd.ExecuteNonQuery()

Sunday, April 23, 2006

Create Table And Insert Syntax

http://www.adp-gmbh.ch/ora/sql/create_table.html

CREATE TABLE ACPG_REMINDER
(protocol_item_id number,
status number,
schedule_type number,
date_due date,
interval_length number,
interval_unit number)
number_of_times number,
iteration_number number)


http://www.1keydata.com/sql/sqlinsert.html
insert into acpg_reminder(protocol_item_id) VALUES (1)

Using an Oracle 9 client to log into an Oracle 10g Express database

After you install Oracle 10g with the defaults enter the following into the 9 tnsnames.ora file.


XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = yourmachinename.yourdomain)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)

ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)

Friday, April 21, 2006

Count Attribute Of DataTable Rows in VB.NET 2003

Where dt is a DataTable

If dt.Rows.Count = 0 Then
result = "dafdadf"
End If

Source: http://www.msde.biz/vbnetfaq.htm

How To Retrieve From A SQL Statement Into A DataSource In VB.NET 2003

Source: http://72.14.203.104/search?q=cache:Jp9APYdBmMEJ:www.programmersheaven.com/2/FAQ-ADONET-Fill-Dataset+dataset+fill+VB.NET&hl=en&gl=us&ct=clnk&cd=5

Imports System
Imports Microsoft.VisualBasic.Strings
Imports Microsoft.VisualBasic.FileSystem
Imports System.IO
Imports System.Data
Imports System.Security
Imports System.Data.Odbc
Imports System.Security.Principal
Imports System.Security.Permissions
Imports System.Threading
Imports MbUnit.Framework
Imports MbUnit.Core.Framework
Imports System.Data.Common
Imports System.Data.OleDb
Imports System.Data.SqlClient


Public Class TestAddPatientToRegistry





Public Sub testClass()

Dim cn As OdbcConnection
Dim cmd As OdbcCommand
Dim result As String
cn = New OdbcConnection("DRIVER={Oracle in OraHome81};SERVER=dev1cdr;UID=ACPG;" & _
"PWD=ACPG;DBQ=dev1cdr;")
Dim mystring As String = "select unit_number as unit_number from ACPG_Reminder R"

cmd = New OdbcCommand(mystring, cn)
cn.Open()
Dim ds As New DataSet
Dim da As OdbcDataAdapter
Dim dt As DataTable
da = New OdbcDataAdapter(cmd)
da.Fill(ds, "R")
dt = ds.Tables("R")
result = dt.Rows(0).Item("unit_number")



Assert.AreEqual(1000005250.ToString(), result)
cn.Close()

cmd.Dispose()

End Sub



End Class

Call member functions directly on numbers in VB.NET 03

1000005250.ToString() works. You can then test this number for equality with its corresponding string and pass.

Explicit Interface Implementation

Boo, like C# has "explicit interface implementation."

It is possible for two interfaces to have the same name. If interfaces were by default visible then there could be confusion as to which member of which interface was being called.

You therefore need to cast your variables explicitly to the interface that you are calling. An example from http://msdn2.microsoft.com/en-us/library/ms173157(VS.80).aspx is as follows:

SampleClass obj = new SampleClass();
//obj.Paint(); // Compiler error.

IControl c = (IControl)obj;
c.Paint(); // Calls IControl.Paint on SampleClass.

ISurface s = (ISurface)obj;
s.Paint(); // Calls ISurface.Paint on SampleClass.