Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom database connections without front page.

Status
Not open for further replies.

andyd273

Programmer
Nov 2, 2005
21
0
0
US
We have a customer database that I would like to be able to pull information from in order to display realtime reports in a sharepoint web part.

I'm writing the web part in VB.Net 2003, and I HATE FrontPage (plus we don't want to use it because of the ghosting issue)

I've tried several different ways of getting it, but so far no luck.

Protected Overrides Sub RenderWebPart(ByVal output As System.Web.UI.HtmlTextWriter)

Dim DS As System.Data.DataSet
Dim Con As System.Data.SqlClient.SqlConnection
Dim Ada As System.Data.SqlClient.SqlDataAdapter
Dim conStr As String

conStr = "server=poweredge1850;uid=****;pwd=****;initial catalog=jl"
Con = New System.Data.SqlClient.SqlConnection(conStr)

Ada = New System.Data.SqlClient.SqlDataAdapter("select * from tblCustomer Where CustomerID=41614", Con)
DS = New System.Data.DataSet
Try
Ada.Fill(DS, "Table1")
Catch ex As Exception
output.Write(ex)
End Try
End Sub

Returns:

System.Security.SecurityException: Request for the permission of type System.Data.SqlClient.SqlClientPermission, System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed. at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet grantedSet, PermissionSet deniedSet, CodeAccessPermission demand, PermissionToken permToken) at System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames, Int32 unrestrictedOverride) at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) at System.Security.CodeAccessPermission.Demand() at System.Data.SqlClient.SqlConnectionString.Demand(SqlConnectionString constr) at System.Data.SqlClient.SqlConnection.Open() at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) at DatabaseConnect_WebPart.DBConnect.RenderWebPart(HtmlTextWriter output)


And
Dim test As New ADODB.Recordset
crashes it completely without even returning the error message. (Error: "The "DBConnect" Web Part appears to be causing a problem")

Is there a way to pull out the information I want without having to resort to the seeping evil that is front page??
 
I should add that I'm trying to connect to a SQL server 2000 database... which is on the same machine as the sharpoint server.
Sharepoint is also using a sql database on this same server, just a different one from the customer database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top