Solved

Creating a SharePoint List item and new directories on network share from Visual Basic 2010

Posted on 2013-01-11
5
518 Views
Last Modified: 2013-01-22
Hello Experts,

I am working on a small windows form application using Visual Basic 2010.
I am looking to accomplish 2 things. (FYI - #1, I got - I need some help with #2)

1. Create a program/windows form (with the following fields: FirstName, LastName, CustomerNumber, and a button to click labeled "create folders") for my employees to fill out that will create several empty folders on a windows network share.

Example:
Z:\Customers
Z:\CustomerName12345
Z:\CustomerName12345\Purchases
Z:\CustomerName12345\Returns
The purpose for doing this is to create some commonality for how my employees manage their folders on my network share.  Note: I do not want users to save files to share point.

I have already achieved this quite easily using My.Computer.FileSystem.CreateDirectory _
("Z:\" & CustomerName & CustomerNumber) and so on for the subdirectories.

2. I created a SharePoint List called "Customers" With 3 fields (FirstName, LastName, and Folder). I want the "Folder" column to be formatted as a hyperlink that links to the appropriate folder (and opens a windows explorer window to that location) which was just created at the same time when my employees click the "create folders" button.

I am not a strong VB programmer and am seeking example code to "create a sharepoint list item" to accomplish this task.

Please let me know if you can help.

Thanks
0
Comment
Question by:MikeXna
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
colly92002 earned 500 total points
ID: 38770449
0
 

Author Comment

by:MikeXna
ID: 38772662
Thanks.  This looks perfect.
Newbie Question: When I pasted the code into my project these first few lines have green underline:

Imports System
Imports Microsoft.SharePoint.Client
Imports SP = Microsoft.SharePoint.Client

When I mouse over them I get the following message:
"Namespace or type specified in the Imports Microsoft.SharePoint.Client doesn't contain any public Member or cannot be found. Make sure the namespace or type is defined and contains at least one public member"

I am sure i am missing something obvious. In visual basic, am I supposed to import any dlls into my solution explorer or something for the code to recognize?

Thanks
0
 
LVL 15

Expert Comment

by:colly92002
ID: 38772981
You are right you need to add the referenced .dlls to the project - if you started a new "Sharepoint" project in visual basic they will be there, but if not, just go to the  references box on the right hand side, right click add reference, and find the microsoft.Sharepoint.client.dll  (you might have to browse to the Sharepoint 14 hive to find it - if in doubt just google its path  because its in a standard directory).   As soon as you have added it it will work.
0
 

Author Comment

by:MikeXna
ID: 38790126
Got the dlls from MS download site after a google search.  The code now works,.
I was able to create a list item -- Thank You

2 Last questions.

1. Does the shareshpoint.client.dll need to be on every client/employee computer? When I build my project the exe in the debug folder works on my pc but not on a computer without the dlls.  Perhaps I am missing something obvious.  I never really published the project.

2. I was only able to create a list item but my text fields are not saving to sharepoint.  I am prompted with an error stating that the field on sharepoint does not exist.  I know it does... Perhaps It is a syntax thing in my code? Can strings be saved to sharepoint plain text fields?

Thanks again.
0
 
LVL 15

Expert Comment

by:colly92002
ID: 38792635
Yes you need the dll on each computer that this is going to run on - you can do this when you package up you project or you can just install the dll manually (I would learn how to build a deplyment package in visual studio personally - search for it in google there are lots of examples).

Sharepoint gives you horrendous error message - the "field does not exist" message just means that "something" is wrong.  It may be the syntax of the command or you maybe addressing your fields incorrectly.  Use the debugger to (put a breakpoint in the code and run the project) step through your code and see what line fails.  Always start by doing the simplest thing you can do and get that working, then build on it.  Sharepoint text fiedls will accept strings without complaint, just make sure there are no control characters in your string that might be confusing things, and that the size of your string is not bigger than your field definition.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now