|
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.
|
|
|
|
|
write your code on form_resize event
check for form.windowstate = FormWindowState.Minimized and write your code to hide your form and show systemtray icon
Vilsad P P
MCTS (Windows Applications) .Net 2.0
|
|
|
|
|
|
Thank You Sir, It is very nice and useful Article.
|
|
|
|
|
workflow is the operational aspect of a work procedure: how tasks are structured, who performs them, what their relative order is, how they are synchronized, how information flows to support the tasks (wordflow) and how tasks are being tracked. As the dimension of time is considered in workflow, workflow considers "throughput" as a distinct
1.shall we develop work flow using using class library from vs.net 2.0
(vb.net)?
2.we need any dedicated language like XPDL for process defination, and link
the process and task ?
please answer to the above questions if you have.
with best Regard's
s.a.Rahman
|
|
|
|
|
*sniff* smells like homework to me...
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have two dates .The difference between them is almost three months and 20 days.How should I programatically calculate the no of days in these start date and end date.Is there any inbuilt function to do it.Or I need to apply my logic to accomplish it.
currently i am using the following code
private sub abc()<br />
Dim startdate As New Date(2006, 1, 1)<br />
Dim enddate As New Date(2006, 3, 1)<br />
Dim str(1) As String<br />
Dim counter As Integer = 0<br />
While (True)<br />
str(counter) = startdate.Day & "-" & Format(startdate, "MMM") & "-" & startdate.Year<br />
counter += 1<br />
ReDim Preserve str(counter)<br />
startdate = startdate.AddDays(1)<br />
If (startdate = enddate) Then<br />
str(counter) = startdate.Day & "-" & MonthName(startdate.Month) & "-" & startdate.Year<br />
Exit While<br />
End If<br />
<br />
End While<br />
End Sub
|
|
|
|
|
I have this code from the net.
We can use this function to find the difference in date,month,year,time.
But it is in C#.
Please try to understand this and convert into VB.NET code.
public enum DateInterval
{
Second, Minute, Hour, Day, Week, Month, Quarter, Year
}
public static long DateDiff(DateInterval Interval, System.DateTime StartDate,
System.DateTime EndDate )
{
long lngDateDiffValue = 0;
System.TimeSpan TS = new System.TimeSpan(EndDate.Ticks - StartDate.Ticks);
switch (Interval)
{
case DateInterval.Day:
lngDateDiffValue = (long) TS.Days;
break;
case DateInterval.Hour:
lngDateDiffValue = (long)TS.TotalHours;
break;
case DateInterval.Minute:
lngDateDiffValue = (long) TS.TotalMinutes;
break;
case DateInterval.Month:
lngDateDiffValue = (long)( TS.Days / 30);
break;
case DateInterval.Quarter:
lngDateDiffValue = (long)( (TS.Days / 30) / 3 );
break;
case DateInterval.Second:
lngDateDiffValue = (long) TS.TotalSeconds;
break;
case DateInterval.Week:
lngDateDiffValue = (long)( TS.Days / 7);
break;
case DateInterval.Year:
lngDateDiffValue = (long)( TS.Days / 365);
break;
}
return (lngDateDiffValue);
}
DateDiff(DateInterval.Day,startdate,endDate)
Hope that helps.
<div class="ForumSig">Regards,
Arun Kumar.A</div>
|
|
|
|
|
Hi Arun
The month, quarter and year calculations in your C# code don't seem very accurate. Can't you just use the VB "DateDiff" function?
Regards
Andy
|
|
|
|
|
andyharman wrote: Can't you just use the VB "DateDiff" function?
Sorry, I do not know much of VB.NET functions,
as I am using C# language.
Any way, thank you very much.
Regards,
Arun Kumar.A
|
|
|
|
|
DateTime.DaysInMonth is the main thing yuo need here.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi, is this what you want to do?
Dim startdate As New Date(2006, 1, 1)
Dim enddate As New Date(2006, 3, 1)
dim s as string
'i just pass the value of startdate & enddate to textbox
txtstartdate=startdate
txtenddate=enddate
'this will calculate the difference of your date
s=DateDiff(DateInterval.Day,strdate,enddate)
Msgbox(s)
is that what you mean dude?sorry if my instinct is wrong.
Don't block the drive way of all the newbies in programming.
|
|
|
|