Jump to content
Xtreme .Net Talk

tbcmartinharvey

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by tbcmartinharvey

  1. This is probably a simple question but i would appreciate some help. I am trying to implement paging with a datagrid that also has a button that allows the user to insert selected information into a datatable thus: <asp:DataGrid id="dg" runat="server" ShowHeader="False" AutoGenerateColumns="False" Width="754px" CellPadding="10" HorizontalAlign="Center" OnItemCommand="AddProduct" DataKeyField="ProductID" OnItemCommand="AddProduct" OnPageIndexChanged="pager" AllowPaging="True" > This works ok if I leave out the paging or the on item Command but they wont work together. If i try to use them together i get the message "Out of range exception". Can anyone tell me where i am going wrong Many thanks Martin For reference the page code is: Sub Page_Load(sender As Object, e AS EventArgs) If Not Page.IsPostBack then dg.DataSource = Catalog.SP_GetInfo() dg.DataBind End If End Sub Sub pager(sender as Object, e As DatagridPageChangedEventArgs) dg.CurrentPageIndex = e.NewPageIndex dg.DataSource = Catalog.SP_GetInfo() dg.DataBind() End Sub Sub AddProduct(sender As Object, e As DataGridCommandEventArgs) ShoppingCart.AddProduct(dg.DataKeys(e.Item.ItemIndex)) End Sub
  2. This is probably a really simple question but i would grateful for some help. I have some text box controls that i want to align vertically with webmatrix. I selected the controls and then tried to use the layout align tools but these dont seem to function. Does anyone know what i am missing. Many thanks Martin
  3. This is probably a very simple problem but i would appreciate some help. I have wired up a datagrid button with the following code. Sub AddProduct(sender As Object, e As DataGridCommandEventArgs) Dim ProductID As Integer = CType(dg.DataKeys(e.Item.ItemIndex), Integer) ' Create the connection object Dim connection As New SqlConnection(ConfigurationSettings.AppSettings("connectionString")) ' Create and initialize the command object Dim command As New SqlCommand("SP_AddToCart", connection) command.CommandType = CommandType.StoredProcedure......................... This code works fine on the page I am trying to compile a public shared function using the following Imports System Imports System.Data ImportS System.Data.SqlClient Imports System.configuration Imports System.Web Namespace worldshop Public Class ShoppingCart Public Shared Function AddProduct(sender As Object, e As DataGridCommandEventArgs) Dim ProductID As Integer = CType(dg.DataKeys(e.Item.ItemIndex), Integer) ' Create the connection object Dim connection As New SqlConnection(connectionString) ' Create and initialize the command object Dim command As New SqlCommand("SP_AddToCart", connection) command.CommandType = CommandType.StoredProcedure But i get the the following error: Public Shared Function AddProduct(sender As Object, e As DataGridCommandEven tArgs) ~~~~~~~~~~~~~~~~~~~~~~~~ C:\worldshopdevelopement\ShoppingCart.vb(53) : error BC30451: ?? 'dg' ?????????? ? Dim ProductID As Integer = CType(dg.DataKeys(e.Item.ItemIndex), Integer) Can anyone tell me where i am going wrong Many thanks Martin
  4. Correct Syntax for returning a dataset many thanks for your help with this martin
  5. I realise this is a simple question but I wonder if anyone can help me with this: Untill now i have been using Datareaders for example; Public Class Catalog Public Shared Function SP_GetBB() As SqlDataReader ' Create the connection object Dim connection As New SqlConnection(ConnectionString) ' Create and initialize the command object Dim command As New SqlCommand("SP_GetBB", connection) command.CommandType = CommandType.StoredProcedure ' Open the connection connection.Open() ' Return a SqlDataReader to the calling function Return command.ExecuteReader(CommandBehavior.CloseConnection) End Function Can anyone tell me how to convert the above to return a Dataset I have got this far but am not sure how to finish: Public Class Catalog Public Shared Function SP_GetBB() As System.Data.DataSet ' Create the connection object Dim connection As New SqlConnection(ConnectionString) ' Create and initialize the command object Dim command As New SqlCommand("SP_GetBB", connection) command.CommandType = CommandType.StoredProcedure......... ................................... many thanks martin
  6. Can anyone help me with this: I am trying to compile a dll from the commnd line with the following code: vbc /debug /nologo /t:library /out:\worldshopdevelopement\bin\Catalog.dll /r:System.dll /r:System.Data.dll \worldshopdevelopement\Catalog.vb The vbc compiler is returning the message: C:\worldshopdevelopement\Catalog.vb(11) : error BC30451: ?? 'CommandType' ?????? ????? command.CommandType = CommandType.StoredProcedure ~~~~~~~~~~~ C:\worldshopdevelopement\Catalog.vb(15) : error BC30451: ?? 'CommandBehavior' ?? ????????? Return command.ExecuteReader(CommandBehavior.CloseConnection) ~~~~~~~~~~~~~~~ C:\worldshopdevelopement\Catalog.vb(20) : error BC30451: ?? 'ConfigurationSettin gs' ??????????? Return ConfigurationSettings.AppSettings("ConnectionString") I Would be really grateful if someone could tell me where i am going wrong Many Thanks Martin For reference the .vb page is as follows: Imports System.Data.SqlClient Public Class Catalog Public Shared Function SP_GetBB() As SqlDataReader ' Create the connection object Dim connection As New SqlConnection(connectionString) ' Create and initialize the command object Dim command As New SqlCommand("SP_GetBB", connection) command.CommandType = CommandType.StoredProcedure ' Open the connection connection.Open() ' Return a SqlDataReader to the calling function Return command.ExecuteReader(CommandBehavior.CloseConnection) End Function Private Shared ReadOnly Property connectionString() As String Get Return ConfigurationSettings.AppSettings("ConnectionString") End Get End Property End Class
  7. I wonder if anyone can help me with this: I am using vbc.exe from the command line to mak a dll with the following code: vbc /t:library Catalog.vb /out:bin/DataLayer.dll /r:System.dll I get two messages: command error 2001: Catalog.vb cannot be found command error 2008 no input sources specified I would be grateful if anyone could help me to solve this problem. For some reason vbc.exe cannot find Catalog.vb Many Thanks Marti
  8. Could anyone help me with a problem I am trying to compile a dll from the command line using vbc.exe. I am using the following code: vbc /t:Library Catalog.vb /r:System.Data.dll /out:bin/Catalog.dll and I keep getting the error message vbc:?????? BC2001: ????'Catalog.vb'??????? Can anyone tell me what the problem is. Many thanks Martin For reference the contents of the Catalog.vb file are as follows: ' Catalog.vb Imports System.Data.SqlClient NameSpace Worldshop Class Catalog Public Shared Function SP_GetBB() As SqlDataReader ' Create the connection object Dim connection As New SqlConnection(connectionString) ' Create and initialize the command object Dim command As New SqlCommand("SP_GetBB", connection) command.CommandType = CommandType.StoredProcedure ' Open the connection connection.Open() ' Return a SqlDataReader to the calling function Return command.ExecuteReader(CommandBehavior.CloseConnection) End Function Private Shared ReadOnly Property connectionString() As String Get Return ConfigurationSettings.AppSettings("ConnectionString") End Get End Property End Class End Namespace
  9. I have created some public classes that I want to access. So far i havent been able to access these classes. Is it necessary to compile these classes together as a dll to access these classes and if it is how do I do this ?. I am using webmatrix with vb.net. Many thanks Martin
  10. 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
×
×
  • Create New...