function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JJoshJLJJoshJL 

sObject Issue

Hey all,

Im getting an error that I cant seem to correct. I am trying to write a test query that will first iterate through a SQL table, and then, if there are no matches, add the new information to SForce. I've managed to correct all issues but this one. After I run the try statement that gets all the needed values, there is the statements

              

Dim sr() As SaveResult = binding.create(accs)

unfortunantly, (accs) comes back with the following error:

 

Value

JJoshJLJJoshJL

ok for whatever reason, my computer just posted the issue like 4 times before I was done. Anwyay, what I was trying to say was that i get an error that says cannot convert to 1- demensional array because sales_logix_update.sforce.sobject is not derived form sales_logix_update.sforce.sobject. This is my last error. Any assistance you can provide is greatly appreciated.

 

Sample Code:

Dim accs(1) As sObject

For j As Integer = 0 To accs.GetUpperBound(0)

account = New Account

If accounts Is Nothing Then

account.AccountNumber = "0000000"

Else

account.AccountNumber = "000000" & (accounts.Length & 1)

End If

'//account.setAnnualRevenue = 4000000.0

account.BillingCity = dr("CITY_CUN")

account.Industry = dr("ACCOUNT_TYPE_CUN")

account.Name = dr("NAME1_CUN")

account.NumberOfEmployees = 40

.

.

.

account.Ownership = "Privately Held"

account.Phone = dr("TELEPHONE_CUN")

account.Website = "www.oz.com"

accs(j) = account

Next

'//create the object(s) by sending the array to the web service

Dim sr() As SaveResult = binding.create(accs)     <------  error here

 

 

DevAngelDevAngel

Hi JJoshJL,

Look okay.  Did figure out why yet?

JJoshJLJJoshJL

Unfortunately no, I did manage to fix a different issue that I thought was related; however, I have pretty much the same error. As a note, if I just set it to say binding.create(accs) instead of sr as saveresults =  binding.create(⬦) then I can get it to run, but it will give me a cannot create account due to request too large. I will provide the entire code this time for this update function as there may be a different issue. Thank you in advance

 

With �dim sr as saveresults = binding.create(accs)

            Error

            Value of type 1dimensional array of sales_logix_update.sforce1.saveresults cannot be converted to sales_logic_update.sforce1.saveresults

 

With just �binding.create(accs)

            Error

            Will run, but receive request to large when attempting to create account information.

 

CODE:

    Private Sub Updatebut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Updatebut.Click

 

 

 

        Dim un As String = "jloct_dev@bbsgjax.com"

        Dim pw As String = ""

 

 

        Console.WriteLine("Creating the binding to the web service...")

        Status.Text = "Creating the binding to the web service..."

 

        binding = New sforce1.SforceService

 

        Console.WriteLine("LOGGING IN NOW....")

        Status.Text = "Logging In Now..."

        loginRes = binding.login(un, pw)

 

        Dim cn1 As New SqlConnection( _

            "Server=SALESLOGIX;DataBase = omd; " & _

            "uid=sysdba;pwd=masterkey")

 

        Dim cn2 As New SqlConnection( _

            "Server=SALESLOGIX;DataBase = omd; " & _

            "uid=sysdba;pwd=masterkey")

 

        Dim cn3 As New SqlConnection( _

            "Server=SALESLOGIX;DataBase = omd; " & _

            "uid=sysdba;pwd=masterkey")

 

        Dim dr As SqlDataReader

        Dim er As SqlDataReader

        Dim fr As SqlDataReader

        Dim cmd As New SqlCommand

        Dim cmd2 As New SqlCommand

        Dim cmd3 As New SqlCommand

 

 

code continued on next post...

 

       

Message Edited by DevAngel on 05-05-2004 01:08 PM

JJoshJLJJoshJL

'sql reader statements here

'open a declerations here

 

While dr.Read

'converts sql to strings

While er.Read

 'verification function here

End While

If test = 0 Then

Try

reads data to new sql table

 Dim account As sforce1.Account

 Dim accs(1) As sforce1.sObject

 For j As Integer = 0 To accs.GetUpperBound(0)

  account = New sforce1.Account

  If accounts Is Nothing Then

   account.AccountNumber = "0000000"

  Else

   account.AccountNumber = "000000" & (accounts.Length & 1)

  End If

   account.BillingCity = dr("CITY_CUN")

   account.BillingCountry = "US"

   account.BillingState = dr("STATE_CUN")

   account.BillingStreet = address1

   account.BillingPostalCode = dr("ZIP_CUN")

   account.Description = "World class hay makers."

   account.Fax = "555.555.5555"

   account.Industry = "Farming"

   account.Name = dr("CUSTOMER_NUMBER")

   account.NumberOfEmployees = 40

   account.Ownership =

   account.Phone =

   account.Website = www.oz.com

   accs(j) = account

   Next

   Dim sr As sforce1.SaveResult

   sr = binding.create(accs)

   Catch ex As Exception

    error message

   End Try

End If

End While

End Sub
DevAngelDevAngel

Hi JJoshJL,

First I think you need to check the logic in your code.  Seems like you don't need the for (j=0...) loop.  If you are inspecting one row of sql data at a time then the j loop will cause 2 records to be added to salesforce.com. 

The declaration for the save result should be

Dim sr() as SaveResult = Binding.create(new sforce1.SObject() {account})

This will create a new save result array filled with the results from the create call.   The parameter is a throw away array constructor.  Or, another way of saying this is that we don't really want the array of SObjects, so we will construct the array in the parameter and not keep a reference to it when the call returns.

Hope this helps.

JJoshJLJJoshJL

yes it does, thanks for your time. Appears to be updating to the dev site now.