|
Cory Kimble wrote: Does Application.StartPath work in .net compact framework
Nope, not supported. You can find out what is and isn't supported in the .NET Framework documentation. Everything with a small phone-looking icon next to it is supported by the Compact framework. Click[^]
|
|
|
|
|
Hi Cory,
Your code is not very clear; here are my assumptions:
1. the files refered to in the lines frmsr = New StreamReader("program files\steidingerfoodsce\localship.txt")
and dim swship as streamwriter = New StreamWriter(localShipFile, False)
are the same
2. sub ReWriteSHIPFile intends to delete the original file.
Under those assumptions I see two potential problems:
1. you do close the streams frmsr (and frmsw) but you fail to dispose of them, although the
documentation says one should dispose of streams. (In fact one should dispose of any class instance
that has a public dispose method). Failing to do so is likely to have negative effects, in this
case I expect the underlying file system does not get cleaned up until the Finalize method is
executed (either by calling dispose explicitly, or by forcing a garbage collection, which happens
to occur when you minimize your form).
2. other processes may have the same file temporarily open (without you being aware); that happens
for fresh files when you have disk indexing enabled, or a gready antivirus program.
in these cases, you should attempt say 5 times in a loop, with 1 second intervals to solve almost
all of it.
Further remarks:
1.
you should avoid similar lines of code, they will lead to mistakes in the end (when you change one
and forget to change the other). Example: swship.WriteLine(frmShip.cmbobxLocation.Text + "," + frmShip.txtbxScanID.Text + "," + frmShip.cmbobxBuyer.Text + "," + dt.ToString("d"))
Solution: calculate the text line once, and (re)use it where ever you need it.
2.
you should avoid magic constants in your code; here "program files\steidingerfoodsce\localship.txt"
should be defined once, at the start of your program, in the initialization code, not in the middle of some
method. And I suspect you already have the variable localShipFile to point to it, so use it consistently.
3.
not sure you should store application data files under "program files". Some Windows versions, and/or some
installations won't let your app write anything there.
4.
I don't like the catch blocks that catch an exception and then ignore it, i.e. only the change-in-flow is used,
not the actual exception. On the other hand, MessageBox.Show(ex.ToString) is excellent; most
programmers use Message or so and miss most of the exception text...
5.
the sequence Flush() followed by Close() is overkill; AFAIK every Close() implies a Flush(), flush is useful
only if you do not intend to close right away but want to make sure the data so far got out to disk anyway.
6.
If the aim of ReWriteSHIPFile() is to delete a possibly existing file, there are better ways to do that.
And remember trying 5 times with 1 sec intervals (as Windows Explorer does, but no single API function offers).
Regards,
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thank you so much for your time and comments.
|
|
|
|
|
I have searched the command for launching EXCEL.EXE with an existed .xls file without any success.
Can someone help me?
Thank in-advanced
|
|
|
|
|
Launch the ".xls" file itself. If Excel is installed, it'll launch and open the file, just like you double-clicked the file yourself.
|
|
|
|
|
Hi DAve,
I am sorry that I did not post the question clearly, what I meant was a valid command code in VB.net source codes in order to execute EXCEL.exe to open an existed .xls file (I do have EXCEL.exe available in my computer)
Anyhelp?
Thanks
|
|
|
|
|
You can find the documentation on the Process class here[^], along with examples on it's use.
|
|
|
|
|
Hi Dave,
Thank for the link, I am able to do what I posted
Thank for help
|
|
|
|
|
i create an update page for my assignment
when i click my update button success msg box appeared
but when i refresh the updated page..only few fields updated
the fields come from 2 different classes
i use datagrid to display the data
|
|
|
|
|
This is great and all, but you haven't saiid anything about the problem you're having, any error messages, what your code looks like, ... nothing anyone can use to help you narrow down the problem.
|
|
|
|
|
**my update statement in my oracle em package
**my update button code
Dim applyprogram As BLL.CApplyProgram = New BLL.CApplyProgram
Dim loanapplication As BLL.CLoanApplication = New BLL.CLoanApplication
applyprogram.ApplyStreamID = Viewstate("APPLYSTREAMID")
applyprogram.laCountryID = ddlCountry.SelectedItem.Value
applyprogram.laFieldID = ddlStudyFields.SelectedItem.Value
applyprogram.laInstituteID = ddlInstitute.SelectedItem.Value
applyprogram.laStreamID = ddlStream.SelectedItem.Value
applyprogram.laProgramID = ddlProgram.SelectedItem.Value
loanapplication.APPID = ViewState("APPID")
loanapplication.LACPROGID = ddlProgram.SelectedItem.Value
loanapplication.LACCOUNTRYID = ddlCountry.SelectedItem.Value
loanapplication.LACSTREAMID = ddlStream.SelectedItem.Value
loanapplication.LACFIELDID = ddlStudyFields.SelectedItem.Value
loanapplication.LACINSTITUTEID = ddlInstitute.SelectedItem.Value
loanapplication.LASTARTEDUCATION = CCommon.MyFormatDate(txtStartDate.Text)
loanapplication.LAYEAREDUCATION = txtYearEducation.Text
loanapplication.LADURATIONYEAR = txtDurationYear.Text
loanapplication.LADURATIONMONTH = txtDurationMonth.Text
applyprogram.Save(BLL.UpdateType.Update)
loanapplication.Save(BLL.UpdateType.Update)
CCommon.CreateMessageAlert(Me, "Record Updated Successfully",
"PromptMessage")
** only few fields (end with smileys) updated
** no error msg
|
|
|
|
|
Ok. This isn't complete by any means. All this does is set a bunch of properties. We'd need to see the code that's behind the Save methods. What does the actual updates to the database?
|
|
|
|
|
hi habibah
What Exactly are you updating ?
Post us your code and point to the Error.
i have once Written an Article about your problem, but that article is for Newbies, for now it will help you
http://www.codeproject.com/KB/vb/N-Tier_Application_VB.aspx[^]
Hope it helps and dont forget to vote for my Article
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
anyone out there who can help me develop a very,very simple game of snake using VB.NET? it is due tomorrow so i really need your help...
it must be until Level 3...
tnx in advance...God bless...
|
|
|
|
|
sakhura_31 wrote: help me develop a very,very simple game of snake using VB.NET?
Maybe we could help if you asked a more specific question about where your stuck.
sakhura_31 wrote: it is due tomorrow so i really need your help...
I certainly hope you started this project at least a couple of weeks ago...
|
|
|
|
|
sakhura_31 wrote: is due tomorrow so i really need your help.
When you fail this assignment, stop and consider if you want to pursue Computer Science or not. IF you do, then do your own homework instead of going out drinking, when it is assigned to you. By all means, if you do your homework and get stuck on specifics, ask here.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am developing an application which i am using crystal report as reporting.
i am getting exception despite i added crystal report .dll in reference.
You are the most welcome to assit me in solving this problem.
Abdul Rahaman Hamidy
Senior Student Student in Computer Science, Kabul, Afghanistan
Interesed in Software Development
|
|
|
|
|
Abdul Rahman Hamidy wrote: You are the most welcome to assit me in solving this problem.
We'd love to help, but you haven't told us what the problem is, other than "I'm getting an exception." What's the exception message?? Without that, we're just guessing at the hundred of possible exception messages you may be getting.
|
|
|
|
|
What error message are you getting? Can you give us a sample of the code that is causing the error? We can't help if you don't give us more information.
|
|
|
|
|
I am trying to work out a simple COM/.NET interop code. In my project in VB, I have created a simple windows application to add two numbers. The functionality of adding is done through the help of a .NET DLL written in C#. I am quite confused by trying various ideas sugggested by people. Can anyone clarify this simply in a step by step fashion?
This my VB code:
<br />
<br />
Private Declare Function method Lib "C:\Documents and Settings\CSfiles\interop\interop\bin\Debug\interop.dll" Alias "interopdll" (ByVal X As Integer, ByVal X As Integer)<br />
<br />
Private Sub Command1_Click()<br />
<br />
Dim a As Integer<br />
Dim obj As Object<br />
<br />
obj = New sample ' I get a compile-time error for undefined user type here.<br />
<br />
a = obj.method(CInt(Text1.Text), CInt(Text2.Text))<br />
Label1.Caption = CStr(a)<br />
<br />
End Sub<br />
<br />
My C#(.NET DLL) Code:
<br />
<br />
using System;<br />
using System.Runtime.InteropServices;<br />
using System.Reflection;<br />
<br />
[assembly: ComVisible(true)]<br />
namespace interop<br />
{<br />
<br />
[ClassInterface(ClassInterfaceType.AutoDual)]<br />
<br />
[GuidAttribute("6CE9C732-CD90-4042-A5F0-CF71DFAC2598")]<br />
<br />
class sample<br />
{<br />
public sample()<br />
{<br />
}<br />
public int c;<br />
<br />
public void method(int a, int b)<br />
{ <br />
c = a+b;<br />
} <br />
}<br />
}<br />
<br />
In this I have registerd the DLL with /codebase switch while using regasm.exe too.
Regards,
Lenus.
|
|
|
|
|
SPanicker* wrote: Private Declare Function method Lib "C:\Documents and Settings\CSfiles\interop\interop\bin\Debug\interop.dll" Alias "interopdll" (ByVal X As Integer, ByVal X As Integer)
Private Sub Command1_Click()
You cannot call a .NET dll from VB6 like this. The .NET compilers don't generate the exports needed for VB6 to call library functions like this.
You'll have to partially scrap the VB6 code and rewrite it along with rewriting the C# .DLL.
The .DLL has to be rewritten so that it's functionality it exposed through COM, if it's not already. Then you can add a reference to the COM-registered .DLL in your VB6 project and call the classes and methods through the COM interface.
|
|
|
|
|
Hi Dave,
Thanks for the info.
Can you just explain this a bit more? Tht is, can you just put the idea across through some demo? Or just provide me with some useful link where I can start up with such a basic tutorial or so?
Regards,
Lenus.
|
|
|
|
|
|
Hi,
I have to run a windows service in .net in which i have to generate popup message box reminder every one hour. i dont want to run it as a application, as each and every time we have to run it manually daily. i cant find a message box in windows service. can anybody please give me an idea of how to do it in an automatic service so that no manual process should be done. once they switch on the system, the service should start automatically and should generate popups once an hour. Pls help.
Thanks and Regards
Vijayarajan.V
|
|
|
|
|
vijay_83 wrote: I have to run a windows service in .net in which i have to generate popup message box reminder every one hour.
Not possible. Web Services cannot generate any kind of a user interface what-so-ever.
<blockquote class="FQ"><div class="FQA">vijay_83 wrote:</div>once they switch on the system, the service should start automatically and should generate popups once an hour.</blockquote>
This sounds like you're trying to write a Windows Service, not a Web Service.
|
|
|
|