|
It's been a LONG time since I've had to do this, but if I remember right there are two things you have to watch, the difference in table names between sql/oracle and I believe you have to refresh the object after you change the provider via .refresh .verifydatabase. That should force it to load the right dlls for the currently assigned provider rather than the one saved with the report.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
|
|
|
|
|
For changing your datasource at run time in case of Crystal Report You can crete your Report connection through DSN.then create DSN as per your requirement.
Best Regard
Anubhava Dimri
mailto: anubhava.prodata@gmail.com
|
|
|
|
|
hi
modified 28-Nov-12 8:51am.
|
|
|
|
|
I didn't read the whole code but check the following
The cases that your code doesn't work are the names different in case (upper / lower case)
String comparison in .net is case sensitive so that might be the problem.
(use string.tolower or string.toupper on both strings that you are comparing to make it case insensitive)
|
|
|
|
|
thanks for that ...
will try it out
|
|
|
|
|
try this
If String.Equals("AAA", "BBB") Then
End If
BR
Jerry
|
|
|
|
|
Hi,
I did not like your post for several reasons:
1. it is not clear what you attempt to achieve. Why couldn't you explain what this is for, and give an example of some data, showing parts that work and parts that don't.
Applying some bold and italic is not the way to explain things.
2. your code looks terrible, I am not going to analyze it. Why can't you apply object-oriented principles to it? you have lines describing some kind of object, hence make that a class, and give it a method to create itself from a text line, and another method to output itself in a format of your choice.
Also try to limit the nesting of conditionals and loops, you have around 10 leading to long code lines requiring lots of horizontal scrolling. When properly coded, the main method would fit on a single screen and it would be much easier to spot the problem.
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi everyone,
I have a form with only one button, "Send", to test the code to send SMTP emails.
It fires the click event when I hit the "Send" button, but the email is never sent if I leave the form running. When I close the form, the email is sent.
This is not the needed behavior because the User may never close the Application or the Form to send emails (this is a Client/Server application, not Web).
Does anyone have an idea why is this happening or what should I change in the code?
Below is the code behind the "Send" button's click event:
Dim message As New MailMessage()
Dim client As New SmtpClient()
'Set the sender's address
message.From = New MailAddress("paulog@corpdev09.com")
message.To.Add(New MailAddress("recipient-test@corpdev09.com"))
message.CC.Add(New MailAddress("paulo-second@corpdev09.com"))
'Set the subject and message body text
message.Subject = "This is the email subject"
message.Body = "This is the body of the email"
'Set the SMTP server to be used to send the message
'client.Host = "DEV-EXCP09-CORPDEV.COM"
'Send the e-mail message
Try
client.Send(message)
Catch exMessage As Exception
MessageBox.show("Error: " + exMessage.Message)
End Try
Thanks,
Paulo
|
|
|
|
|
Have you tried using SendAsync(message) instead of Send(message) ?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Henry,
Thanks for your answer. Yes, I changed the code and tried SendAsync with the same result in VB. I also got the below code snipe in C#:
private static void SendAynchronousEmail(SmtpClient client)
{
MailMessage message = new MailMessage();
message.To.Add(RecipientEmail);
message.From = new MailAddress(SenderEmail);
message.Subject = "Asynchronous Email Test";
message.Body = "This is a test email, sent asynchronously.";
client.SendCompleted += new SendCompletedEventHandler
(mailDeliveryComplete);
client.SendAsync(message, "Test");
Console.WriteLine("Sending finished, press Enter.");
Console.ReadLine();
}
It sends the email only after you hit Enter. If you remove the Console.ReadLine()the email is never sent!
The code in the mailDeliveryComplete just write in the console "Message Sent".
I'm lost.
All code snipes I see in books and Internet are straight forward like above but none works, only after you close the application.
Any idea what is missing?
Thanks,
Paulo
|
|
|
|
|
My guess is the Console is behaving in a logical way and you are fooling yourself. Whenever you execute Console.ReadLine() the console awaits your input and delays all its output. So "Message Sent" can not be shown as long as you don't hit ENTER.
To prove this, add the following right after Console.ReadLine():
Console.WriteLine("please hit ENTER once more");
Console.ReadLine();
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi Luc,
Yes, you are right. But the point is not the command console.readline() but the fact that if I remove it the email is not sent.
In MSDN I found that if you use the synchronous Send method your code does not goes until the request is completed. This is why I'm using SendAsync that is asynchronous and it should not wait and send the email, not matter what the code does after.
I put the console.readline() only to be able to see the messages, I never tought that if I remove it the email is never sent.
Must be a reason for that...
Thanks for you reply. I'm still trying to find a way to send SMTP emails without having to finish the thread.
Thanks,
Paulo
|
|
|
|
|
See what happens if you follow Lucs' suggestion.
I'll watch the thread, in case you come back.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Paulo,
I have a C# program that, amongst a lot of other stuff, contains mail code, basically identical to yours (the synchronous version, that is):
MailMessage msg=new MailMessage();
...
SmtpClient client = new SmtpClient(server);
client.Send(msg);
The only difference is my client is constructed with the server's name as a parameter.
My program successfully sends three mails without exiting at all.
My best guess is your observation somehow is wrong.
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Thursday, March 26, 2009 4:23 PM
|
|
|
|
|
Hi Luc/Henry,
I tried to build the SMTP client as Luc suggested but did not work either.
However, I found what the problem was: follow me.
when I started this project I did not know if I'll be using MAPI or SMTP, so I wrote 2 methods. Testing the MAPI time ago (with MAPI we use here Exchange Server), when the email is sent ExchangeServer pops a dialog box telling me that a program (my application) "is trying to send an email on your behalf" and give me an OK and CANCEL buttons. Once I hit OK, the email is sent.
That is the key: I'm testing the code using my own equipment, sending emails to me to see if it works or not. Did you see what happened?
SMTP does not have all Exchange Server features and does not issue a dialog asking for authorization, but it keeps waiting because I'm sending emails from my equipment to myself, but the user is not me, is my application, using my credencials!
As a proof of concept for this theory, I installed the application in another computer in the network and it worked fine, no more need to close the sending thread!
Nothing is wrong with those VB and C# codes, just the way I'm testing.
So, Luc/Henry, I really appreciate your effords and time spent to help me and it was a good felling having someone in the other side to discuss with my tech problems.
Thank you!
Paulo
|
|
|
|
|
Hi Paulo,
glad you got it working.
However I'm not familiar with Exchange Server, and I do not quite follow your reasoning.
Are you saying:
1. Exchange Server does not want to accept your app sending something until the app exits?
2. Exchange Server does not deliver the newly received message as long as the app is running, because the app is impersonating you and "you" (the app) are not asking for incoming mail until the app exits and your regular mail client becomes active again?
Furthermore: would your app succeed in sending without exiting, if you did close your mail client beforehand?
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi Luc,
About exchange server, it asks for authorization because the app (that is not me) is using my credencials to send email. This also happens when you get a virus kind Trojan and it tries to send emails from your equipment (it did happened before with me). The antivirus also catch this kind too.
I noticed that because the confirmation dialog box exchange server issued. But now I'm not using exchange server and MAPI, I'm using our SMTP server and it does not issue a dialog. If I issue 3 or 4 emails all go to the SMTP queue and all are sent only when the task is closed.
But if I use other equipment than mine, it works fine.
I tried to close the mail session bforehand, but it did not work either.
Anyways, it is something to keep in mind for our future development needs.
Thanks Luc.
Anytime.
Paulo
|
|
|
|
|
Ok I'm trying to make a simple inkball type game.
But, I'm getting some wierd errors. Here is my code.
Public Class Form1
Public ink() As Point
Public g As Graphics = Me.CreateGraphics
Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
Dim p = ink.Length
ink(p).X = e.X
ink(p).Y = e.Y
End If
End Sub
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
For Each p As Point In ink
g.DrawRectangle(Pens.Black, New Rectangle(p.X, p.Y, 1, 1))
Next
End Sub
End Class
I've tried changing g to be Panel1.creategraphics, since the panel is what it would be drawing on but that causes even more problems. The errors I am getting are all 'Object Reference Not set to an instance of an object."
Have you tried the Krypton Toolkit? http://www.componentfactory.com/free-windows-forms-controls.php
|
|
|
|
|
I really don't understand what you are trying to do , but the error you are getting is because you have not initialized the array ink() , it is still Nothing and hence are getting the error , was not able to understand the logic you are trying to apply , looking at the code it don't think it is going draw anything . The only thing i can suggest is initialized the array before using it.
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
The graphics object you created is one for the form, not the panel. You get the graphics object for the panel from the Panel1 Paint event, like this:
Private Sub Panel1_Paint(ByVal sender as System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
Dim g As Graphics = e.Graphics
For Each p As Point In Ink
g.Draw....
Next
End Sub
But, of course, you'll have to modify the paint code to check to see if there are any points at all in the Ink array.
|
|
|
|
|
i am just wondering if anyone know(or have links) of a way to save a array inside the application code?
If at first you don't succeed
redefine success
J.Hardy
modified on Wednesday, March 25, 2009 9:52 PM
|
|
|
|
|
Dim p(3) As Point 'create an array of 4 points (1-3 and 0)
p(0) = New Point(640, 480) 'assign values to the points
p(1) = New Point(800, 600)
p(2) = New Point(1280, 748)
p(3) = New Point(769, 999)
Dim r As New String("") 'create a blank string
For Each ipoint As Point In p 'loop through the points
r &= "Point is located at: " & ipoint.ToString & vbNewLine 'write a string about the point
Next
MessageBox.Show(r) 'display the string with the info
Hope it helps!
Have you tried the Krypton Toolkit? http://www.componentfactory.com/free-windows-forms-controls.php
|
|
|
|
|
sorry allow me to explain better, when i publish my application to a exe i need to store a array inside the exe(this will make the application grow in size), so next time when i open it the contents of the array will be there
If at first you don't succeed
Redefine success
J.Hardy
|
|
|
|
|
You don't save data in your exe, you save it in an external file (for example app.config or as user settings) and load it in - unless you are talking about an hardcoded set of values, in which case the code to populate the array will be in the exe anyway.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
dam, oh well, thanks anyway
If at first you don't succeed
Redefine success
J.Hardy
|
|
|
|
|