tbcmartinharvey Posted October 7, 2005 Posted October 7, 2005 I would really be grateful for some help. I realize this is probably a very basic question but can someone tell me how to do this. I have created a class function that uses a stored procedure to return a datareader. (I am using webmatrix) I want to bind this datareader to a datagrid. I have been using dg.datasource=classfunctionnname" but I get a compile error saying the class function hasnt been declared. I have included the the class function below: Namespace System.Data.SqlClient Public Class Catalog Public Shared Function SP_GetBB() As SqlDataReader Dim Connection as New SqlConnection(ConnectionString) Dim command As New SqlCommand(CommandText,Connection) Dim CommandText As String = "SP_GetBB" Command.CommandType = CommandType.StoredProcedure Connection.Open() Return Command.ExecuteReader(CommandBehaviour.CloseConnection) End Function Private Shared ReadOnly Property connectionString() As String Get Return ConfigurationSettings.AppSettings("ConnectionString") End Get End Property End Class End Namespace I have tried Dim dr1 As SqlClient.SqlDataReader = Catalog.SP_GetBB dg.datasource = dr1 But no combination I try seems to work. I was wondering if this is a namespace problem Scott Mitchell wrote that you cannot use the web.config Appsettings unless you include the relevant namespaces in the page. http://aspnet.4guysfromrolla.com/articles/122403-1.aspx Maybe class functions are the same. If anyone could hellp me i would be grateful Quote
Administrators PlausiblyDamp Posted October 7, 2005 Administrators Posted October 7, 2005 (edited) You would need to prefix Catalog with it's namespace, however you seem to be putting it into the already existing System.dat.sqlclient namespace - is there a reason for this, usually you would want to extend the system provided namespaces in this manor. Edited October 7, 2005 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.