|
I have removed the old class.
|
|
|
|
|
Removed the reference and added it again and still no luck.
|
|
|
|
|
before you re-addedit, did you first compile the webservice with the new class?
|
|
|
|
|
are you using web reference or going after the webservice dynamically?
if web reference -- try to remove the reference and re-add it...
|
|
|
|
|
I am adding a web reference to it.
I have removed it, recompiled the service and added it again and still has the same problem.
|
|
|
|
|
Well I have managed to achieve what I want to but in a pretty crude way.
I have written a function to serialize a class and one to deserialize it.
Like this -
Public Function Object2XML(ByVal obj As Object) As String<br />
Dim SW As New StringWriter<br />
Dim Ser As New XmlSerializer(obj.GetType())<br />
Try<br />
Ser.Serialize(SW, obj)<br />
Return SW.ToString<br />
Catch ex As Exception<br />
Throw ex<br />
End Try<br />
End Function<br />
<br />
Public Function XML2OBject(ByVal xml As String, ByVal Type As Type) As Object<br />
Dim Obj As New Object<br />
Dim SR As New StringReader(xml)<br />
Dim Serializer As New System.Xml.Serialization.XmlSerializer(Type)<br />
Try<br />
Return Serializer.Deserialize(SR)<br />
Catch ex As Exception<br />
Throw ex<br />
End Try<br />
End Function
But surely there is a better way to do it than this?
|
|
|
|
|
if you want, you can email your solution and I can take a quick look (strip out any unnecessary code)
|
|
|
|
|
Thats a very kind offer but It is as very large project and I can't strip it easily.
Don't think my boss would appreciate me sending you the whole of our site.
Thanks anyway.
Have you managed to pass a custom class to a web service before successfully?
|
|
|
|
|
yes we do it all the time. we do not however use web references (not that I think that's the problem). we go after the webservice dynamically...
|
|
|
|
|
How do you go after the webservice dynamically as you put it?
|
|
|
|
|
let me put a quick sample together...
|
|
|
|
|
example:
include system.web.services in your exe project
make the webservice (if not already) a virtual directory
the line - Me.Url = "http://localhost/cpwebproj/PopulateMyObj.asmx"
allows you to change localhost to any ip/dns name
hope this helps...
********this goes in your dll***********
<Serializable()> _
Public Class MyObj
Public sName As String
Public sAddr As String
Public sCity As String
Public sState As String
Public sZip As String
End Class
********this goes in your exe***********
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim oEntity As New CPDllProj.MyObj
Dim oTrans As New Trans
oEntity = oTrans.Request(oEntity)
MsgBox(oEntity.sName)
MsgBox(oEntity.sAddr)
MsgBox(oEntity.sCity)
MsgBox(oEntity.sState)
MsgBox(oEntity.sZip)
End
End Sub
end class
Imports System.Web.Services
Imports System.Web.Services.Protocols
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Web.Services.WebServiceBindingAttribute(Name:="CPHandlerSoap", [Namespace]:="CPWebProj/PopulateMyObj")> _
Public Class Trans
Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
<System.Web.Services.Protocols.SoapDocumentMethodAttribute("CPWebProj/PopulateMyObj/Request", _
RequestNamespace:="CPWebProj/PopulateMyObj", _
ResponseNamespace:="CPWebProj/PopulateMyObj", _
Use:=System.Web.Services.Description.SoapBindingUse.Literal, _
ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _
Public Function Request(ByVal oEntity As CPDllProj.MyObj) As CPDllProj.MyObj
Dim oa() As Object
Me.Url = "http://localhost/cpwebproj/PopulateMyObj.asmx"
Me.Timeout = 60000
oa = Me.Invoke("Request", New Object() {oEntity})
Return CType(oa(0), CPDllProj.MyObj)
End Function
End Class
********this goes in your webservice***********
Imports System.Web.Services
<System.Web.Services.WebService(Namespace:="CPWebProj/PopulateMyObj")> _
Public Class PopulateMyObj
Inherits System.Web.Services.WebService
#Region " Web Services Designer Generated Code "
Public Sub New()
MyBase.New()
'This call is required by the Web Services Designer.
InitializeComponent()
'Add your own initialization code after the InitializeComponent() call
End Sub
'Required by the Web Services Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Web Services Designer
'It can be modified using the Web Services Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
'CODEGEN: This procedure is required by the Web Services Designer
'Do not modify it using the code editor.
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#End Region
<WebMethod(), _
System.Xml.Serialization.XmlInclude(GetType(CPDllProj.MyObj))> _
Public Function Request(ByVal oEntity As CPDllProj.MyObj) As CPDllProj.MyObj
oEntity.sName = "me"
oEntity.sAddr = "123 test st"
oEntity.sCity = "testy town"
oEntity.sState = "IL"
oEntity.sZip = "60000"
Return oEntity
End Function
End Class
|
|
|
|
|
Thanks very much for your help.
But i'm afraid you've got a bit beyond me there.
|
|
|
|
|
maybe, maybe not...
do this and I'll show you how I got the code I sent:
+add a webrefence to your asmx page.
+right-click on the new reference and left-click on view in object browser
+expand the plus
+right-click on your class name
+left-click on goto definition
if you look the upper part of the code, its your routine name showing it's pointing to localhost. this is the code I sent you...
|
|
|
|
|
"+add a webrefence to your asmx page."
You mean add a webreference to my web service?
In which case a reference to what?
If you meant add a web reference to my consuming project I have and tried clicking view in browser but it was greyed out.
|
|
|
|
|
For some reason view in browser is no longer gereyed out (no idea what I've done).
but there is no option to view in object browser.
|
|
|
|
|
in your exe, rightclick on the references and choose add web reference
yes point to your web service
using my example is would look like
http://localhost/cpwebproj/populatemyobj.asmx
not view in browser, view in 'object browser'
|
|
|
|
|
The webreference appears as a folder with 3 files inside none of which have an option to view in object browser on right click.
|
|
|
|
|
Hi all,
First of all I'll apologise in advance! I'm very new to this and have been trying to learn through books and what I can pick up on the net so I'm hoping someone can help me understand where I'm going wrong with the following...
I've set up a datagrid which works perfectly when I use textboxes, however I'm trying to limit user choice by adding dropdownlists to the datagrid. I get as far as clicking to edit the field and get the following error:
---------------------------
System.IndexOutOfRangeException: StatusID
Source Error:
Line 345:
Line 346: <edititemtemplate>
Line 347: <asp:dropdownlist id="ddlStatusctrl" runat="server"
line="" 348:="" datatextfield="Status" 349:="" datavaluefield="StatusID"
=""
----------------------------
my="" coding="" for="" the="" dropdownlist="" is="" as="" follows:
="" <asp:templatecolumn="">
<headertemplate>
Status
<itemtemplate>
<%# Container.DataItem("Status") %>
<edititemtemplate>
<asp:dropdownlist id="ddlStatusctrl" runat="server"
="" datatextfield="Status" datavaluefield="StatusID" datasource="<%# GetStatus() %>" selectedindex="<%# GetSelectedIndex(Container.DataItem("StatusID")) %>">
and VB code is :
to populate the dataset ('Dim DS as DataSet = New DataSet()' declared globally) ...
Function GetStatus() as DataSet
Dim DBConn as OleDbConnection
Dim DBCommand as OleDbDataAdapter
DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("data/Auto_log.mdb") & ";")
DBCommand = New OleDbDataAdapter("SELECT StatusID, Status from Status ORDER BY Status", DBConn)
DBCommand.Fill(DS, "Status")
DBConn.Close()
Return DS
End Function
----------------
to get selected index -
Function GetSelectedIndex(ByVal StatusID As String) As Integer
'Loop through the DataSet DS
Dim iLoop As Integer
Dim DT As DataTable = DS.Tables("Status")
For iLoop = 0 To DT.Rows.Count - 1
If StatusID = DT.Rows(iLoop)("StatusID").ToString Then
Return iLoop
End If
Next iLoop
End Function
-----------
... & to update the database (cut to show coding related to ddl)-
Sub dg_Update(s As Object, e As DataGridCommandEventArgs)
Dim ddlStatus As DropDownList = FindControl("ddlStatusctrl")
strCmd = "UPDATE AutomationHist SET System=@System, Status=@ddlStatus, ProgramNo=@ProgramNo, VersionNo=@VersionNo, LastJobNo=@LastJobNo, Date_Last_Amended=@Date_Last_AmendedParam, Date_Authorised=@Date_AuthorisedParam, Coded_by=@Coded_by, Location=@Location, Calculation=@Calculation, Writeback=@Writeback, Letter_output=@Letter_output, Exceptions=@Exceptions, Comments=@Comments WHERE Primary_Key=@Primary_Key"
objCmd.Parameters.Add("@ddlStatus", ddlStatus)
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()
dgAutomationHist.EditItemIndex = -1
BindData()
End Sub
------------------
Thanks very much in advance...
-- modified at 7:21 Thursday 10th May, 2007
-- modified at 7:27 Thursday 10th May, 2007
-- modified at 7:41 Thursday 10th May, 2007
Robster
|
|
|
|
|
I have maked this code and it work nice, for me
Now i want to exclude fronm column ordering the filed named "DATA_AGG" how to?
here the mdb in access:www.mytempdir.com/1323897
Option Explicit
Sub ORDER_FILEDS()
Dim DATABASE As DAO.DATABASE
Dim TABELLA As DAO.TableDef
Dim CAMPO_TEMP As DAO.Field
Dim POSIZIONE() As Integer
Dim CAMPO_NOME() As String
Dim INT_TEMP As Integer
Set DATABASE = OpenDatabase("\\GCD01F4500\DATI\PUBBLICA\ANTIRIC\OPERATORI.MDB")
Set TABELLA = DATABASE.TableDefs("TEST")
With TABELLA
ReDim POSIZIONE(0 To .Fields.Count - 1) As Integer
ReDim CAMPO_NOME(0 To .Fields.Count - 1) As String
For INT_TEMP = 0 To .Fields.Count - 1
POSIZIONE(INT_TEMP) = .Fields(INT_TEMP).OrdinalPosition
CAMPO_NOME(INT_TEMP) = .Fields(INT_TEMP).Name
Next INT_TEMP
For Each CAMPO_TEMP In .Fields
CAMPO_TEMP.OrdinalPosition = 1
Next CAMPO_TEMP
End With
DATABASE.Close
End Sub
|
|
|
|
|
because you are no longer dealing with a 1 to 1, you need to use a different varaible for the posizione and camp_nome.
dim INT_ACC as integer = 0
For INT_TEMP = 0 To .Fields.Count - 1
If .Fields(INT_TEMP).Name <> "DATA_AGG" Then
POSIZIONE(INT_ACC) = .Fields(INT_TEMP).OrdinalPosition
CAMPO_NOME(INT_ACC) = .Fields(INT_TEMP).Name
INT_ACC = INT_ACC + 1
End If
Next INT_TEMP
|
|
|
|
|
When i minimize my application then i want it to hide as i have a tray icon and then i can open it from there
But i am not able to catch form's Minimize button event
How can i minimize the form(hide)
|
|
|
|
|
Public Class MinimizeInTray<br />
Public TrayMenu As New ContextMenu<br />
Public Restorewindowstate As FormWindowState = <br />
FormWindowState.Normal<br />
Public trayicon As New NotifyIcon<br />
Public mainform As New Form<br />
Public visible As Boolean = False<br />
Sub New(ByVal form As Form, Optional ByVal icontext As String = "", <br />
Optional ByVal icon As Icon = Nothing)<br />
TrayMenu.MenuItems.Clear()<br />
mainform = form<br />
TrayMenu.MenuItems.Add("Restore", AddressOf restore)<br />
TrayMenu.MenuItems.Add("Close", AddressOf close)<br />
AddHandler trayicon.DoubleClick, AddressOf restore<br />
With trayicon<br />
.Visible = False<br />
If IsNothing(icon) Then<br />
.Icon = mainform.Icon<br />
Else<br />
.Icon = icon<br />
End If<br />
.Text = icontext<br />
.ContextMenu = TrayMenu<br />
End With<br />
End Sub<br />
Private Sub restore(ByVal sender As System.Object, ByVal e As <br />
System.EventArgs)<br />
mainform.ShowInTaskbar = True<br />
visible = True<br />
trayicon.Visible = False<br />
mainform.WindowState = Restorewindowstate<br />
End Sub<br />
Private Sub close(ByVal sender As System.Object, ByVal e As <br />
System.EventArgs)<br />
trayicon.Visible = False<br />
mainform.Close()<br />
End Sub<br />
End Class
|
|
|
|
|
Thanks for the code but what i want is something like outlook.
if i minimize my form then it should not be visible.
Not only minimize from tray icon but also from minimize button of the form to.
|
|
|
|
|
I think same code should work .
just add a button to the form which indiacates the minimize sign.
and put the code on that i same send.
|
|
|
|