Inserting values into custom class error
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
Inserting values into custom class error

 
Post new topic   Reply to topic    Windows Server Forum Index -> Commerce Server
Author Message
Alexander Yushchenko
Guest





Posted: Tue Aug 16, 2005 4:52 pm    Post subject: Inserting values into custom class error Reply with quote

I use MSCS2002 + SP3 + FP1

I have extended dw with a custom class Region_ZipCode (consisting
of 2 fields) with the use of 'CreateSchemaObject.vbs' script from SDK:

CreateClassDef cn, "Region_ZipCode", "test_Source", "", True, 0, ""
CreateMemberDef cn, "Region_ZipCode", "Zip", "WSTR8",
fGenerateColDef + fIsRequired + fPrimaryKey + fHasDefaultVal, "0", ""
CreateMemberDef cn, "Region_ZipCode", "Region_ID", "NUMBER",
fGenerateColDef + fIsRequired, "", ""

After that I try to execute the following code (written in c#):

ADODB.Connection adoConnection = new ADODB.ConnectionClass();
adoConnection.Open("Provider=commerce.dso.1;Data
Source=mscop://InProcConnect/Server=my_server:
Catalog=DWSchema:Database=my_database:FastLoad=True:Connection_Retry=10:Connection_Retry_Delay=30",
"my_user", "my_password", 0);
object nullObject = Type.Missing;
adoConnection.Execute("DELETE FROM Metro_ZipCode", out nullObject, 0);
adoConnection.Execute("INSERT INTO Region_ZipCode (Region_ID, Zip)
VALUES (1, '99999')", out nullObject, 0);
adoConnection.Close();


The first "Execute" command is successful.
The second one throws the following exception: "Exception from
HRESULT: 0xCA2D8038." And no more information.

Please, advice.

--
Yours faithfully,
Alexander Yushchenko
Back to top
Brian Blum [MSFT]
Guest





Posted: Wed Aug 17, 2005 8:52 pm    Post subject: RE: Inserting values into custom class error Reply with quote

The CSOLEDB Provider doesn't support insert. You have to use the url
binding syntax to write data.

Below is a sample that writes an instance into the TaskHistory class.

Private Function SetTransactionStatus(dStarttime As Date, dEndTime As Date,
lTaskId As Long, sSiteName As String, iStatus As Integer) As Boolean

On Error GoTo lblError
Dim rec As ADODB.Record
Set rec = New ADODB.Record
rec.Open "instance/TaskHistory", g_CnProvider, adModeWrite,
adCreateCollection

rec("TaskID") = lTaskId
rec("OperationID") = SynTaskOperationId
rec("Status") = iStatus
rec("StartTime") = dStarttime
rec("EndTime") = dEndTime
rec("Description") = LoadResString(resSyncTask) & ":" &
oOptions.sDescription
rec("CommerceSiteName") = sSiteName
rec("SourceInfo") = g_sServer & "/MSCS_Admin"
rec("NumberOfTries") = 1
If iStatus = 1 Then
rec("PercentageComplete") = 100
End If


rec("__Commit") = 1
rec.Fields.Update ' required with the win2000 RC1 builds and after
rec.Close
rec.Open "instance/TaskHistory", g_CnProvider, adModeWrite,
adCreateCollection
rec("__Commit") = 2
rec.Fields.Update
rec.Close
Set rec = Nothing

SetTransactionStatus = True
Exit Function

lblError:
Set rec = Nothing
SetTransactionStatus = False
End Function
--------------------
Date: Tue, 16 Aug 2005 19:35:26 +0400
From: Alexander Yushchenko <sasha-yoush@mtu-net.ru>
User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
X-Accept-Language: ru-ru, ru
MIME-Version: 1.0
Subject: Inserting values into custom class error
Content-Type: text/plain; charset=KOI8-R; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <uTcThgnoFHA.2956@TK2MSFTNGP10.phx.gbl>
Newsgroups:
microsoft.public.commerceserver.datawarehousing,microsoft.public.commerceser
ver.general
NNTP-Posting-Host: mipt.server.ru 194.67.183.7
Lines: 1
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.commerceserver.general:3213
microsoft.public.commerceserver.datawarehousing:490
X-Tomcat-NG: microsoft.public.commerceserver.general

I use MSCS2002 + SP3 + FP1

I have extended dw with a custom class Region_ZipCode (consisting
of 2 fields) with the use of 'CreateSchemaObject.vbs' script from SDK:

CreateClassDef cn, "Region_ZipCode", "test_Source", "", True, 0, ""
CreateMemberDef cn, "Region_ZipCode", "Zip", "WSTR8",
fGenerateColDef + fIsRequired + fPrimaryKey + fHasDefaultVal, "0", ""
CreateMemberDef cn, "Region_ZipCode", "Region_ID", "NUMBER",
fGenerateColDef + fIsRequired, "", ""

After that I try to execute the following code (written in c#):

ADODB.Connection adoConnection = new ADODB.ConnectionClass();
adoConnection.Open("Provider=commerce.dso.1;Data
Source=mscop://InProcConnect/Server=my_server:
Catalog=DWSchema:Database=my_database:FastLoad=True:Connection_Retry=10:Conn
ection_Retry_Delay=30",
"my_user", "my_password", 0);
object nullObject = Type.Missing;
adoConnection.Execute("DELETE FROM Metro_ZipCode", out nullObject, 0);
adoConnection.Execute("INSERT INTO Region_ZipCode (Region_ID, Zip)
VALUES (1, '99999')", out nullObject, 0);
adoConnection.Close();


The first "Execute" command is successful.
The second one throws the following exception: "Exception from
HRESULT: 0xCA2D8038." And no more information.

Please, advice.

--
Yours faithfully,
Alexander Yushchenko


This posting is provided "AS IS" with no warranties, and confers no rights.

EBusiness Server Team
Back to top
Alexander Yushchenko
Guest





Posted: Thu Aug 18, 2005 12:52 pm    Post subject: Re: Inserting values into custom class error Reply with quote

Thanks for your answer!

The solution you suggested works.

But why do you say that insert is not supported? According to MSDN,
it is:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csvr2002/htm/cs_rp_oledb_yxkd.asp

--
Yours faithfully,
Alexander Yushchenko


Brian Blum [MSFT] wrote:
Quote:
The CSOLEDB Provider doesn't support insert. You have to use the url
binding syntax to write data.

Below is a sample that writes an instance into the TaskHistory class.
Back to top
Brian Blum [MSFT]
Guest





Posted: Thu Aug 18, 2005 8:52 pm    Post subject: Re: Inserting values into custom class error Reply with quote

The CSOLEDB Provider supports two modes of operation; fastload and
singleinstance. The mode is determined by the connection string parameter
Fastload.

Fastload does NOT support the command syntax, although there is a DELETE
command.

Singleinstance mode is used by the Profile subsystem, and does support the
SELECT, INSERT, UPDATE and DELETE statements.

Since your connection string specified Fastload=true, you can't INSERT, but
I should have been more clear the modes.
--------------------
Date: Thu, 18 Aug 2005 13:50:16 +0400
From: Alexander Yushchenko <sasha-yoush@mtu-net.ru>
User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
X-Accept-Language: ru-ru, ru
MIME-Version: 1.0
Subject: Re: Inserting values into custom class error
References: <uTcThgnoFHA.2956@TK2MSFTNGP10.phx.gbl>
<B7gIhU1oFHA.3120@TK2MSFTNGXA01.phx.gbl>
In-Reply-To: <B7gIhU1oFHA.3120@TK2MSFTNGXA01.phx.gbl>
Content-Type: text/plain; charset=KOI8-R; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <egJw9o9oFHA.2156@TK2MSFTNGP14.phx.gbl>
Newsgroups: microsoft.public.commerceserver.general
NNTP-Posting-Host: mipt.server.ru 194.67.183.7
Lines: 1
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.commerceserver.general:3235
X-Tomcat-NG: microsoft.public.commerceserver.general

Thanks for your answer!

The solution you suggested works.

But why do you say that insert is not supported? According to MSDN,
it is:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csvr2002/ht
m/cs_rp_oledb_yxkd.asp

--
Yours faithfully,
Alexander Yushchenko


Brian Blum [MSFT] wrote:
Quote:
The CSOLEDB Provider doesn't support insert. You have to use the url
binding syntax to write data.

Below is a sample that writes an instance into the TaskHistory class.


This posting is provided "AS IS" with no warranties, and confers no rights.

EBusiness Server Team
Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> Commerce Server All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB