Can someone PLEASE help me with my newest problem:
I am working in VB.NET Windows Application off of this
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/tscSPListItem.asp

Using the example to get data out of a list...here is my code snippit:
Dim context
Dim siteCollection As SPSite = SPControl.GetContextSite(Context) -->The
Context as written in the URL above isn't Dim'd anywhere, anyone know
why?<--
Dim srcList As SPList = siteCollection.AllWebs("Team Web Site").Lists("PIN
Numbers")
Dim listItems As SPListItemCollection = srcList.Items
Dim listitem As SPListItem
For Each listitem In listItems
Label3.Text += SPEncode.HtmlEncode(listitem("UserName")) & " :: " &
SPEncode.HtmlEncode(listitem("PIN")) & "<br>"
Next listitem

Now, I know that something is not quite right cause I am throwing some
really wierd exceptions:

An unhandled exception of type 'System.IO.FileNotFoundException' occured in
system.windows.forms.dll.
Additional information: File or assembly name Microsoft.SharePoint.Library,
or one of its dependencies, was not found.

Here are my (relevant) references:
Microsoft.Sharepoint points at Microsoft.Sharepoint.Dll correctly

I am importing:
System, System.xml, Microsoft.Sharepoint, Microsoft.Sharepoint.Utilities,
Microsoft.Sharepoint.WebControls

Is there another (easier) way to simply return the values of a Sharepoint
List so that I can display them in a label?

Please help!!! :-)
Derek

Re: Getting data from a List by Derek

Derek
Tue Jan 06 11:09:28 CST 2004

I guess another way of asking this question should be:
Using VB.NET in a Windows App, I would like to retrieve data from a specific
list and put it in a label.
Can someone assist?

Derek




"Derek Martin" <dmj2195@okstate.edu> wrote in message
news:%23k1evHH1DHA.2528@TK2MSFTNGP09.phx.gbl...
> Can someone PLEASE help me with my newest problem:
> I am working in VB.NET Windows Application off of this
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/tscSPListItem.asp
>
> Using the example to get data out of a list...here is my code snippit:
> Dim context
> Dim siteCollection As SPSite = SPControl.GetContextSite(Context) -->The
> Context as written in the URL above isn't Dim'd anywhere, anyone know
> why?<--
> Dim srcList As SPList = siteCollection.AllWebs("Team Web Site").Lists("PIN
> Numbers")
> Dim listItems As SPListItemCollection = srcList.Items
> Dim listitem As SPListItem
> For Each listitem In listItems
> Label3.Text += SPEncode.HtmlEncode(listitem("UserName")) & " :: " &
> SPEncode.HtmlEncode(listitem("PIN")) & "<br>"
> Next listitem
>
> Now, I know that something is not quite right cause I am throwing some
> really wierd exceptions:
>
> An unhandled exception of type 'System.IO.FileNotFoundException' occured
in
> system.windows.forms.dll.
> Additional information: File or assembly name
Microsoft.SharePoint.Library,
> or one of its dependencies, was not found.
>
> Here are my (relevant) references:
> Microsoft.Sharepoint points at Microsoft.Sharepoint.Dll correctly
>
> I am importing:
> System, System.xml, Microsoft.Sharepoint, Microsoft.Sharepoint.Utilities,
> Microsoft.Sharepoint.WebControls
>
> Is there another (easier) way to simply return the values of a Sharepoint
> List so that I can display them in a label?
>
> Please help!!! :-)
> Derek
>
>



Re: Getting data from a List by Derek

Derek
Wed Jan 07 09:59:33 CST 2004

Well, after not hearing from anyone, I came to the conlusion that no one had
ever done this before, so in case someone at some time needs to actually get
data into an application from Sharepoint, after several hours of digging,
was able to cludge something together. Here is some example code:

'This requires a web reference to your Sharepoint site pointing at
sitename/_vti_bin/DspSts.asmx
'The list structure I am retrieving looks like this: Column 1: UserName,
Column 2: PIN Number. I am doing a comparison of the entered values with
the values of what is in the list (not included)
'On login, perform these actions: Get the user's name from bob(0), get the
data entered into the
'PIN field, connect to the Sharepoint list, retrieve the PIN of the user's
ID that is passed by bob(1),
'compare the PIN numbers, if equal, proceed to timeclock.vb, else error.

Public PINList As String 'This is the variable that sets the identifyer
of the PIN List, created as public as it is going to be referenced in other
classes of my application.
PINList = "{233F3007-D6F2-40E3-9A49-A050284D40B4}" 'This is the List
Identifyer of the site
Dim myPin As String 'Container for the PIN Number as returned by
Sharepoint when queried
Dim myStsAd As New listretrieval.StsAdapter
myStsAd.Credentials = System.Net.CredentialCache.DefaultCredentials

Dim vArray(0) As String 'Required for data retrivals.
vArray(0) = "1.0"
Dim myVersion As New listretrieval.Versions
myVersion.version = vArray
myStsAd.versions = myVersion

Dim reqHeader As New listretrieval.RequestHeader
reqHeader.document = listretrieval.DocumentType.content
reqHeader.method = listretrieval.MethodType.query
myStsAd.request = reqHeader

Dim myRequest As New listretrieval.QueryRequest
Dim sQuery As New listretrieval.DSQuery
sQuery.select = "/list[@id='" + PINList + "']" 'Note that PINList is
referenced here.
myRequest.dsQuery = sQuery
Dim spQuery As New listretrieval.DspQuery
Dim xmlDoc = New System.Xml.XmlDocument
'This is the query on the referenced list that is performed
Dim ndQuery As XmlElement = xmlDoc.CreateElement("Eq")
ndQuery.InnerXml = "<FieldRef Name='UserName'/>" & _
"<Value>" + bob + "</Value>"
spQuery.Where = ndQuery
'Bob is used here as the text username as the PIN numbers are in this
format: UserName and PIN both as text

'In the PIN list, the UserName is not stored as the ID number of the user
for ease of use.
myRequest.dsQuery.Query = spQuery
Try
Dim myNode As XmlNode = myStsAd.Query(myRequest)
'This message box will display the results of the UserName lookup as a full
XML Document
'MessageBox.Show(myNode.OuterXml)
Dim xmlread As XmlDocument = New XmlDocument
Dim pin_node As XmlNode =
myNode.SelectSingleNode("descendant::PIN_x0020_Numbers")
Dim title_node As XmlNode =
pin_node.SelectSingleNode("descendant::Title")
If title_node Is Nothing Then 'If the resulting XPath filter contains no
data, then a PIN Number has not been assigned.
MessageBox.Show("PIN Number not assigned!")
Else
myPin = title_node.InnerText 'The PIN contains data, therefore it is
assigned and given to the myPin variable for comparison with the data
entered in the text box.
End If

Catch ex As System.Web.Services.Protocols.SoapException 'Catch any
exceptions thrown here.
MessageBox.Show(ex.Message & ex.StackTrace)
'End of the List retrival stuff
End Try

I hope that helps anyone out there that needs to do this stuff. :-) If
anyone finds a better way of doing it, let me know...



"Derek Martin" <dmj2195@okstate.edu> wrote in message
news:%23k1evHH1DHA.2528@TK2MSFTNGP09.phx.gbl...
> Can someone PLEASE help me with my newest problem:
> I am working in VB.NET Windows Application off of this
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/tscSPListItem.asp
>
> Using the example to get data out of a list...here is my code snippit:
> Dim context
> Dim siteCollection As SPSite = SPControl.GetContextSite(Context) -->The
> Context as written in the URL above isn't Dim'd anywhere, anyone know
> why?<--
> Dim srcList As SPList = siteCollection.AllWebs("Team Web Site").Lists("PIN
> Numbers")
> Dim listItems As SPListItemCollection = srcList.Items
> Dim listitem As SPListItem
> For Each listitem In listItems
> Label3.Text += SPEncode.HtmlEncode(listitem("UserName")) & " :: " &
> SPEncode.HtmlEncode(listitem("PIN")) & "<br>"
> Next listitem
>
> Now, I know that something is not quite right cause I am throwing some
> really wierd exceptions:
>
> An unhandled exception of type 'System.IO.FileNotFoundException' occured
in
> system.windows.forms.dll.
> Additional information: File or assembly name
Microsoft.SharePoint.Library,
> or one of its dependencies, was not found.
>
> Here are my (relevant) references:
> Microsoft.Sharepoint points at Microsoft.Sharepoint.Dll correctly
>
> I am importing:
> System, System.xml, Microsoft.Sharepoint, Microsoft.Sharepoint.Utilities,
> Microsoft.Sharepoint.WebControls
>
> Is there another (easier) way to simply return the values of a Sharepoint
> List so that I can display them in a label?
>
> Please help!!! :-)
> Derek
>
>



Re: Getting data from a List by Gregg

Gregg
Thu Jan 08 11:48:02 CST 2004

Derek

I would normally field these types of questions but I have been away from
the group for the week. Yes in fact a good number of people have done jsut
what you are asking about - and regularly too. What you have found is a step
in the right direction. In the example you gave - the reason you are getting
errors is that is SharePoint Object Model code and it ONLY works on the
SharePoint server. To get SharePoint info into a client Windows based Forms
app you need to use web services (or potentially something more exotic like
.Net remoting.......but I digress). You can do thiss one of 2 ways:

First is by using the default shipped web services that come with
SharePoint. These are not generally the preferred path for in-house
development. They are highly generalized and usually require more work just
in configuring the calls than in getting product from them. You really
should use the (very nice) SharePoint object model to develop your own data
request/management web services. The OM is infanitly easier to work with
PLUS you will get the benefit of doing your processing on the server rather
than on the client - see?

The SDK has a very good intro to developing your own web services

"Derek Martin" <dmj2195@okstate.edu> wrote in message
news:%23k1evHH1DHA.2528@TK2MSFTNGP09.phx.gbl...
> Can someone PLEASE help me with my newest problem:
> I am working in VB.NET Windows Application off of this
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/tscSPListItem.asp
>
> Using the example to get data out of a list...here is my code snippit:
> Dim context
> Dim siteCollection As SPSite = SPControl.GetContextSite(Context) -->The
> Context as written in the URL above isn't Dim'd anywhere, anyone know
> why?<--
> Dim srcList As SPList = siteCollection.AllWebs("Team Web Site").Lists("PIN
> Numbers")
> Dim listItems As SPListItemCollection = srcList.Items
> Dim listitem As SPListItem
> For Each listitem In listItems
> Label3.Text += SPEncode.HtmlEncode(listitem("UserName")) & " :: " &
> SPEncode.HtmlEncode(listitem("PIN")) & "<br>"
> Next listitem
>
> Now, I know that something is not quite right cause I am throwing some
> really wierd exceptions:
>
> An unhandled exception of type 'System.IO.FileNotFoundException' occured
in
> system.windows.forms.dll.
> Additional information: File or assembly name
Microsoft.SharePoint.Library,
> or one of its dependencies, was not found.
>
> Here are my (relevant) references:
> Microsoft.Sharepoint points at Microsoft.Sharepoint.Dll correctly
>
> I am importing:
> System, System.xml, Microsoft.Sharepoint, Microsoft.Sharepoint.Utilities,
> Microsoft.Sharepoint.WebControls
>
> Is there another (easier) way to simply return the values of a Sharepoint
> List so that I can display them in a label?
>
> Please help!!! :-)
> Derek
>
>