Mimer SQL Data Provider
Inserting user defined type from application class
Mimer SQL Data Provider > Overview > Working with user defined types > Inserting user defined type from application class

In the following example the class defined in the Selecting user defined type into application class called myaddress is used. When storing data in the database user defined types must be passed to the database server. This can be done with the  MimerUserDefinedType class. Consider the following SQL types and table:

create type streetno as integer;
create type address as (street varchar(30), streetnumber streetno);
create table person(personid int, home address);

And the following code:

MimerConnection conn = new MimerConnection(connectionString);
try {
     conn.Open();
    
MimerCommand comm1 = new MimerCommand("insert into person(personid, home) values(?, ?)", conn);
    
//
    
// We add parameters for the two columns 
     //
    
MimerParameter par1 = new MimerParameter();
     MimerParameter par2 = new MimerParameter();
     comm1.Parameters.Add(par1);
     comm1.Parameters.Add(par2);
     par1.Value = -4;   // Personid
     myaddress myaddr = new myaddress();
     myaddr.street = "Arlington road";
     myaddr.streetno = 10;
     par2.Value = myaddr;
     comm1.ExecuteNonQuery();

In the example the data is inserted into the person table. Each question mark in the SQL statement represents one parameter passed from the application by using a MimerParameter. The value of the column home is populated by instantiating a myaddress instance.

See Also

Basic insert
Selecting user defined type into application class