Dear all,
Anybody knows about Sharepoint Portal Server (SPS) and Sharepoint
Services? There's a component named Web Parts in SPS which is very
similar to Web Custom Controls. I'm trying to make a web part which can
retrieve data from SQL Server 2000 and XML files.
I made 2 functions in order to retrieve the data. One is GetAuthors,
which retrieves records from table authors in database pubs (SQL
Server), and the other is GetCustomer, which retrieves data from a XML
file.
These functions always generate errors. The first one generates error in
line containing: oAdapter.Fill(mDS, "authors"). The error message:
Request for the permission of type
System.Data.SqlClient.SqlClientPermission, System.Data,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
failed.
The second generates error:
Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
failed.
Anybody knows what are the problems and how to solve these errors? The
source code is attached at the bottom.
One more question: I installed SQL 2000 Reporting Services on the same
PC where I installed SPS. My Question:
I want the authenticated users in SPS (from Windows Authentication) to
be able to access the reports which is stored in SQL Reporting Services.
What should I do?
Thank you,
Han
-----------------------------------------------------
Imports System
Imports System.Data
Imports System.Web.UI
Imports System.ComponentModel
Imports System.Web.UI.HtmlControls
Imports System.Runtime.InteropServices
Imports Microsoft.SharePoint.WebPartPages
<ToolboxData("<{0}:DataAccessDemo runat=server></{0}:DataAccessDemo>"),
Guid("ED40BE64-49E1-40a2-BF48-859D528551A1")> _
Public Class DataAccessDemo
Inherits WebPart
Dim WithEvents oButtonGetAuthor As New HtmlButton
Dim WithEvents oButtonGetCustomer As New HtmlButton
Dim oID As New HtmlInputText
Dim oName As New HtmlInputText
Private mDS As DataSet
Private mDT As DataTable
Private mDR As DataRow
Private Sub oButtonGetAuthor_ServerClick(ByVal sender As Object,
ByVal e As System.EventArgs) Handles oButtonGetAuthor.ServerClick
GetAuthor()
End Sub
Private Sub oButtonGetCustomer_ServerClick(ByVal sender As Object,
ByVal e As System.EventArgs) Handles oButtonGetCustomer.ServerClick
GetCustomer()
End Sub
Protected Overrides Sub CreateChildControls()
oButtonGetAuthor.InnerText = "Get Author"
Controls.Add(oButtonGetAuthor)
oButtonGetCustomer.InnerText = "Get Customer"
Controls.Add(oButtonGetCustomer)
oID.Value = ""
Controls.Add(oID)
oName.Value = ""
Controls.Add(oName)
End Sub
Protected Overrides Sub RenderWebPart(ByVal output As
System.Web.UI.HtmlTextWriter)
oID.RenderControl(output)
oName.RenderControl(output)
output.WriteLine("<br>")
oButtonGetAuthor.RenderControl(output)
oButtonGetCustomer.RenderControl(output)
End Sub
Private Function ConnectStringBuild() As String
Dim strConn As String
strConn &= "Data Source=(local);"
strConn &= "Initial Catalog=pubs;"
strConn &= "User ID=sa;"
strConn &= "[EMAIL PROTECTED];"
Return strConn
End Function
Private Sub GetAuthor()
Dim oAdapter As SqlClient.SqlDataAdapter
Dim strSQL As String
Dim strConn As String
strConn = ConnectStringBuild()
strSQL = "SELECT * FROM authors"
mDS = New DataSet
Try
oAdapter = New SqlClient.SqlDataAdapter(strSQL, strConn)
oAdapter.Fill(mDS, "authors")
mDT = mDS.Tables("authors")
mDT.PrimaryKey = New DataColumn() {mDT.Columns("au_id")}
mDR = mDT.Rows(0)
oID.Value = mDR.Item("au_id")
oName.Value = mDR.Item("au_fname")
Catch ex As Exception
oID.Value = "Error GetAuthor"
oName.Value = ex.Message
End Try
End Sub
Public Sub GetCustomer()
Dim dsNorthwind As New DataSet("Northwind")
Dim dtCustomer As DataTable
Dim drCustomer As DataRow
Try
Dim strXMLPath As String
strXMLPath = Page.Server.MapPath("/bin/Customers.XML")
dsNorthwind.ReadXml(strXMLPath, XmlReadMode.ReadSchema)
dtCustomer = dsNorthwind.Tables("Customers")
drCustomer = dtCustomer.Rows(0)
oName.ID = drCustomer.Item(0)
oName.Value = drCustomer.Item(1)
Catch ex As Exception
oID.Value = "Error"
oName.Value = ex.Message
End Try
End Sub
End Class
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/k7folB/TM
--------------------------------------------------------------------~->
'// =======================================================
Rules : http://ReliableAnswers.com/List/Rules.asp
Home : http://groups.yahoo.com/group/vbHelp/
=======================================================
Post : [EMAIL PROTECTED]
Join : [EMAIL PROTECTED]
Leave : [EMAIL PROTECTED]
'// =======================================================
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/vbhelp/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/