.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Post New Web Links

Code to import data from external db and add to SPList ONLY if it does not already exist in the SPLi

Posted By:      Posted Date: September 25, 2010    Points: 0   Category :SharePoint
 

So I'm failry new at peogramming and really new at programming for SharePoint. I have created a custom timer job to run a stored procedure to import data into a custom SP List.  Got that to work fine. now I need the job to read the data in the list and if the row already exists, to scrap the incoming row. Here is a couple snippets of my code. It fails in the nested for each loop. I think I have either the CAML wrong or the loops are backwards or otherwise messed up.

    static SPListItemCollection QueryList(SPList list)
    {
      try
      {

        SPQuery listQuery = new SPQuery();
        //listQuery.Query = "<Where><IsNotNull><FieldRef Name='Alert_x0020_ID' /></IsNotNull></Where><OrderBy><FieldRef Name='Alert_x0020_ID' Ascending='True' /></OrderBy>";
        listQuery.ViewFields = @"<FieldRef Name='Alert_x0020_ID' />";
        SPListItemCollection collListItems = list.GetItems(listQuery);

        return collListItems;
      }
      catch
      {
        
                                     
                                            
                                        

View Complete Post


More Related Resource Links

Adding SPListItem to a SPList with External Data Column

  
I used SharePoint 2010's BCS to create an external content type. I added a list column of the type "External Data" to a custom list. 1. When I add an Item through the SharePoint interface, the external data field is displayed correctly in the view. 2. I add the item using the following code:   SPListItem newItem = customList.Items.Add(); newItem["Title" ] = "Test" ; newItem["ExternalDataColumnTest" ] = "1111" ; newItem.Update();   Now, When i go to the list, i can see the new item, but the External Data Column is empty in the view. When I use the ECB action "View Item", i can see that the primary key of my external data type item was saved. When I use the ECB action "Edit Item", the external data column field is empty. When I compare the item I added with the one I added through code in the VS2010 debugger, they hold exactly the same value ("1111" in example above). Any advice would be greatly appreciated.  

Toolbox: Data Snapshots, Subversion, Source Code Organization and More

  

If you want to save, organize, and annotate snapshots of your database data, find an easy way to install and configure Subversion, and automate the organization of your source code, then you'll want to read more about these latest tools.

Scott Mitchell

MSDN Magazine August 2009


Under the Table: How Data Access Code Affects Database Performance

  

In this article, the author delves into some commonly used ways of writing data access code and looks at the effect they can have on performance.

Bob Beauchemin

MSDN Magazine August 2009


Smart Storage: Protect Your Data Via Managed Code And The Windows Vista Smart Card APIs

  

Smart cards are a compelling alternative to the reliance on passwords, which are the weakest link in authentication systems. Get the Windows smart card programming basics here.

Dan Griffin

MSDN Magazine November 2006


Toolbox: Protecting Code, Persisting Data, and More

  

This month obfuscating your code, persisting your data, and a good read on SQL Server 2005.

Scott Mitchell

MSDN Magazine October 2006


Know Thy Code: Simplify Data Layer Unit Testing using Enterprise Services

  

If you want to employ unit testing and test-driven development techniques in your database application development process, you'll have different factors to consider than you do when you're not involving a database. For example, you have to maintain a consistent state within the database and be able to roll back transactions when necessary. This article shows you how to get the best of unit testing for your database apps in a safe, usable manner.

Roy Osherove

MSDN Magazine June 2005


Trustworthy Code: Exchange Data More Securely with XML Signatures and Encryption

  

You can sign any kind of data using XML Signature, including part of an XML document, other XML documents, or other data of any format. However, in practice, XML signatures are most frequently used to sign other data represented in XML. In this article, the authors discuss the new standard and how you can benefit from it in your apps.

Mike Downen and Shawn Farkas

MSDN Magazine November 2004


Data: More Load, Less Code with the Data Enhancements of ASP.NET 2.0

  

A data source control is a server control that wraps some basic functions of a data source - be it a SQL Server database, an XML document, an Excel worksheet, or a sitemap description. Through the services of a similar component, data-bound controls can fetch data as well as insert new records or update and delete existing ones. Data source controls enable a consistent model across a variety of data sources and dramatically reduce the amount of code needed to implement a two-way data-binding scenario. This article provides an introduction to data source controls and other related data binding features.

Dino Esposito

MSDN Magazine June 2004


XML Schemas: Take Advantage of Existing External XML Schemas with a Custom Import Framework in ASP.N

  

Over the years, many industry-standard XML schemas and dialects have been developed. These industry-specific schemas embrace the original purpose of XML and are extremely valuable in promoting and supporting B2B interaction. Unfortunately, the ASP.NET Web Services runtime does not allow developers to directly reference external schemas from within their XML Web Services interface (the WSDL file). This article builds an external schema framework as an extension to the ASP.NET Web Services runtime to enable you to reference external schemas within your XML Web Service interface.

Scott Short

MSDN Magazine December 2002


Trying to run a stored procedure from vb code with oracle data provider.

  

Hello,

Here is my SP:

create or replace
PROCEDURE ZGETUSERSSIGNONS (vUid IN VARCHAR2, p_getuserssignon_recordset1 OUT SYS_REFCURSOR) AS
BEGIN
 Open p_getuserssignon_recordset1 for
 SELECT Distinct(Userid), UserPassword, SecurityLevel, ActiveStatus
FROM ZSIGNON
WHERE substr(UserId,1,2) <> vUid
Order By UserId;
END ZGETUSERSSIGNONS;

I would like to run this SP from code and fill a gridview with the result. 

I am not sure how to go about this, as I have found several different examples, other than the one I  think I need.

I am using the oracle data provider and I have an input parameter (vUid, which will equal "zz").

First question. When filling a gridview with a result set from a stored procedure should the recordset OUT be defined as a REFCURSOR (like i did above)? 

Second:

Do you have example code as to how to execute the SP and fill a gridview?  I keep trying different variations of code i've found on the internet without any success other than getting more confused.

(I am using VS 2005, VB).

Thank you.

 

 


Creating a SharePoint 2010 Web Part That Can Read and Write Data to an External Data Source

  
Learn to use Visual Studio 2010 to create a Visual Web Part that uses a BCS external content type in SharePoint Server 2010 to read and write data to the AdventureWorks sample database.

Sample: Creating a SharePoint 2010 Web Part That Can Read and Write Data to an External Data Source

  
Explore the code in this visual how-to article as you learn to use Visual Studio 2010 to create a Visual Web Part that uses a BCS external content type in SharePoint Server 2010.

Creating .NET Assemblies That Aggregate Data from Multiple External Systems for Business Connectivit

  
This article describes a quick, four-step process for creating a .NET assembly that BCS can use to retrieve external data for SharePoint Server 2010 by using Visual Studio 2010.

Consuming External Data Using SharePoint Server 2010 Business Connectivity Services and an Excel 201

  
Learn how to use BCS in SharePoint Server 2010 to access and update external data by using Microsoft Excel 2010 as a client.

Accessing BLOB Data from External Systems Using Business Connectivity Services in SharePoint Server

  
Learn how to use BCS in SharePoint Server 2010 to access and surface BLOB data in the SharePoint user interface and search.

Sample: Accessing BLOB Data from External Systems Using Business Connectivity Services in SharePoint

  
Download sample code as you learn to use BCS in SharePoint Server 2010 to access and surface BLOB data in the SharePoint user interface and search.

Integrating External Data and Microsoft SharePoint 2010 Platform Services in Microsoft Office 2010 S

  
Microsoft Office 2010 integrates with SharePoint more closely than in previous versions. The resources here show you how to take advantage of the powerful collaboration infrastructure.
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend