|
Quote: are you missing a using directive or an assembly reference? Add the assembly (dll) where UserInfoaa is defined.
Make sure that that assembly does not have a "zone identifier" with the value of "Internet" (on the level of the NTFS file system).
|
|
|
|
|
how to adding code message box to successful message sending and i'am have to failed sent but successful nothing. this is the source code use c# 2008. Thanks for help me
private void button_Send(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == quot;" || textBox3.Text == "")
{
MessageBox.Show("Please Fill Required field");
}
else
try
{
obj_SMTPClient = new SmtpClient("smtp.gmail.com");
Obj_MailMsg = new MailMessage();
obj_Attachment = new System.Net.Mail.Attachment(label3.Text);
Obj_MailMsg.From = new MailAddress(textBox1.Text);
Obj_MailMsg.To.Add(textBox3.Text);
Obj_MailMsg.Body = textBox5.Text;
Obj_MailMsg.Attachments.Add(obj_Attachment);
Obj_MailMsg.Subject = textBox4.Text;
SmtpClient smtps = new SmtpClient("smtp.gmail.com", 587);
obj_SMTPClient.Credentials = new NetworkCredential();
obj_SMTPClient.Port = 587;
obj_SMTPClient.Credentials = new System.Net.NetworkCredential(textBox1.Text, textBox2.Text);
obj_SMTPClient.EnableSsl = true;
obj_SMTPClient.Send(Obj_MailMsg);
}
catch
{
MessageBox.Show("Sorry TimeOut");
}
}
|
|
|
|
|
Try:
obj_SMTPClient.EnableSsl = true;
obj_SMTPClient.Send(Obj_MailMsg);
MessageBox.Show("Sent successfully");
}
catch
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
|
You're welcome!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
|
Hi ALL !
I want to execute this by OledbDataReader when I want to take ... :
string CalcQuery = @"SELECT SUM(BuyAmount) From SubTblMetal WHERE IDMetal=" + int.Parse(txtId.ToString());
OleDbCommand cmdCacl;
cnnCalc.Open();
cmdCacl = new OleDbCommand(CalcQuery, cnnCalc);
OleDbDataReader dr;
dr = cmdCacl.ExecuteReader();
if (dr.HasRows==false)
{
txtBuyAmount.Text = "0";
throw new Exception();
}
else if (dr.Read())
{
txtBuyAmount.Text = dr[0].ToString();
}
But when my DataReader has not any row ,I have an error for the value of txtBuAmount.Text
please Help , how can get the value of Zero (0) , when dataRow has not any row(value).
Thanks a lot !
|
|
|
|
|
First off, please use a parameterized query rather than concatenating the value into the statement.
Next, don't trust HasRows.
Also, why is that throw in there?
As you are expecting at most one value, you might do better with ExecuteScalar and then test for DBNull.Value (for when ther are no matching records).
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Very nicely explained
If You Never Try You’ll Never Know
|
|
|
|
|
I want To do This :
BuyAmount.Text = "0";
When there is No Row in dataReader
thanks
|
|
|
|
|
I understand, but are there ever no rows? Or do you get a NULL (DBNull.Value) when there are no matching rows?
Even if you do get no rows, it's better to handle that with an else on the other if . You don't need two if s; you don't need to test HasRows .
HasRows is not a member of the IDataReader[^] interface so you can't count on it being in every database system you use (if you ever have to use multiple database system, like I do). Every time I've tried to use HasRows I got burnt.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Yes , thanks , I use If and else when dbIsNull . It works .
|
|
|
|
|
Hello everybody!
At first, I was making a mood(emotion) detection desktop app in real time from a web camera using Human Emotion Detection from Image[^] as reference, but unfortunately, I failed at this.
Then , I tried something else ; I searched for a pre-made mood detection in real time app to integrate it as out-tool program. So, I found at http://www.ginktage.com/2011/08/using-face-api-in-c/[^] that there was an API web site called www.face.com which provided what I wanted and a library for c# . But again, unfortunately, it doesn't exist anymore.
So, my question is:
Do you know something similar to www.face.com for mood detection in real time , which can be used in c# and can you give examples how to use it in c#? Or at least, a c# open source program for mood detection in real time?
Thank you in advance for your help!
|
|
|
|
|
Intel provides the RealSense SDK which has this capability.
|
|
|
|
|
I´ve set up business logic handling a connection of a clientsoftware to a serversoftware.
That BL is encapsulated in this interface:
public interface IServerConnectionLogic
{
IObservable<bool> Connected { get; }
Task Connect();
...
}
Connect());
In my viewmodel (based on ReactiveObject) I create my commands, that should trigger the server-connection:
CmdConnectToService = new ReactiveCommand(ServerConnectionLogic.Connected.Select(connected => !connected));
CmdConnectToService.Subscribe(_ => ServerConnectionLogic.Connect());
The command is bound to a button in my UI-XAML.
When pressing the button the subscribed lamda is hit and the "Connect" method is called.
Inside the Observable "Connected" is set to "true.
Also the lambda in the "CanExecute"-parameter of the constructor of the ReactiveCommand is hit.
But the UI is not updated. I would have expected the button to get disabled, sinde the observable "Connected" turns to "true" and the "Select" statement inverts my boolean value...
I´ve tried that with the "RibbonButton" from the WpfToolkit as well as with a "normal" Button. Both are not getting updated.
The same IObservable<bool> is also bound to a member field:
m_ServerConnected = new ObservableAsPropertyHelper<bool>(ServerConnectionLogic.Connected, _ => raisePropertyChanged("ServerConnected"));
while "m_ServerConnected" is bound to a CheckBox (for testing) via a property. That one is working fine, so the observable must be working...
Does anyone have an idea what could be my issue?
|
|
|
|
|
public class Sample{
BindingList<something> Some;
public Sample(ref BindingList<something> some)
{
Some = some;
}
}
That class should be keep alive until the application will be closed "hmm that was a bad practice!" but i need it because it will monitor the db if there is a changes in data.
then i have this:
public static Sample s = new Sample(ref SomeVariable)
Now when i passes the SomeVariable with data it is working fine, any changes of the variable "Some" of the Sample class it is reflected to the SomeVariable.
Now the problem rise if the SomeVariable has a 0(zero) items on it and passed to constructor (SomeVariable here is properly initiated), then if the Sample class found changes in the db the SomeVariable is not updated.
I will appreciate for any help will come.
Thank you,
Gilbert
|
|
|
|
|
Sorry?
That is a little confused to me - remember that we can't see your screen, access your HDD, or read your mind.
If you want a class instance that exists until the application is closed, then that won't necessarily do it: you want to use a static class, because your existing example can still be Disposed by the GC if there are no references to it. Or just declare an instance in your main form.
Other than that, I can;t work out what you are saying...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
sorry for that, i will include now the real code
public abstract class DBSynchronizer<T> : IDBSynchronizer
where T : GCSC.Interface.IEditableObject
{
protected EditableObjectEventHandler onEditableObjectRaised;
protected EditableList<T> referencedItem;
protected bool hasNewItems, hasModifiedItems, hasRemovedItems;
protected List<int> idsNew, idsOld;
protected EditableList<T> tempSourceType;
protected StringBuilder tempSB;
protected MySQLSelect tempMySQLSelect;
Timer Ticker;
int track, defaultIterationBeforeSleep, cycle;
bool isTickerStarted;
int kickStarter;
public DBSynchronizer(ref EditableList<T> itemCollection)
{
referencedItem = itemCollection;
IsInitialized = referencedItem.Count < 1 ? false : true;
IterationBeforeSleep = 5;
MaxSleepTime = 60000;
Interval = 1000;
}
protected virtual void CollectNewItems(string query)
{
tempMySQLSelect = new MySQLSelect(query);
if (tempMySQLSelect.RowCount < 1)
{
hasNewItems = false;
return;
}
hasNewItems = true;
tempSourceType = new EditableList<T>(tempMySQLSelect.Reader());
tempMySQLSelect.Clear();
foreach (var ni in tempSourceType)
referencedItem.Add(ni);
tempSourceType = null;
}
public virtual void ForceCollectNewItem()
{
CollectNewItems(NewItemQuery);
}
protected abstract void CollectModifiedItems();
protected abstract void CollectRemovedItems();
public abstract void NotifyAllSubscriber();
private void Ticker_Tick(object sender, EventArgs e)
{
if (referencedItem.Count > 0)
{
CollectRemovedItems();
CollectModifiedItems();
}
CollectNewItems(NewItemQuery);
}
protected virtual void Initialize()
{
if (isTickerStarted)
return;
defaultIterationBeforeSleep = IterationBeforeSleep;
IsInitialized = true;
isTickerStarted = true;
Ticker = new Timer() { Interval = Interval, Enabled = true };
Ticker.Tick += Ticker_Tick;
Ticker.Start();
}
public virtual void ForceAwake()
{
if (!isTickerStarted)
return;
if (Ticker != null)
if (Ticker.Interval == Interval)
return;
Ticker.Dispose();
Ticker = new Timer() { Interval = Interval, Enabled = true };
Ticker.Tick += Ticker_Tick;
Ticker.Start();
}
public virtual void Shutdown()
{
if (Ticker == null) return;
Ticker.Dispose();
}
protected virtual int Timing()
{
if (MaxSleepTime < 1000) throw new ArgumentException("MaxSleepTime must not be less than or equal 1000", "MaxSleepTime");
return new RandomNumber(1000, MaxSleepTime).GetRandomNumber();
}
public int IterationBeforeSleep { get; set; }
public bool IsInitialized { get; protected set; }
public bool IsSleep { get; protected set; }
public int Interval { get; set; }
public int ForceShutdownAt { get; set; }
public int MaxSleepTime { get; set; }
protected abstract string NewItemQuery { get; }
public event EditableObjectEventHandler EditableObjectRaised
{
add
{
Initialize();
onEditableObjectRaised += value;
}
remove { onEditableObjectRaised -= value; }
}
}
Then it was inhereted here
internal sealed class SynchronizePersonClass : DBSynchronizer<PersonsClass>
{
static readonly object _locker = new object();
public SynchronizePersonClass(ref EditableList<PersonsClass> itemCollection)
: base(ref itemCollection) { }
protected override void CollectModifiedItems()
{
}
protected override void CollectRemovedItems()
{
}
protected override void Initialize()
{
lock (_locker)
{
if (!IsInitialized)
ProcessClass<PersonsClass>.PopulateCollection(ref ClassCollections.PersonClassColletction,
ReadOnlyStrings.TBL_PERSON + " WHERE `is_deleted` = 0 ORDER BY `registration_date` DESC");
base.Initialize();
}
}
public override void NotifyAllSubscriber()
{
if (onEditableObjectRaised == null) return;
onEditableObjectRaised(this, new EditableObjectEventArgs(referencedItem));
referencedItem.Finalized();
}
protected override string NewItemQuery
{
get
{
return ReadOnlyStrings.TBL_PERSON + " WHERE `is_deleted` = 0 AND `tbl_person_id` NOT IN(" +
getIDCollectionString() + ") ORDER BY `registration_date` DESC";
}
}
private string getIDCollectionString()
{
if (referencedItem.Count < 1) return "0";
tempSB = new StringBuilder(referencedItem.Count * 2);
foreach (var ri in referencedItem)
tempSB.Append(ri.PersonID + ", ");
return tempSB.Remove(tempSB.Length - 2, 2).ToString();
}
}
then create a static object of it
internal class Synchronizers
{
public static SynchronizePersonClass PersonClassSynchronizer;
}
the initializing the bindinglist
ProcessClass<PersonsClass>.PopulateCollection(ref ClassCollections.PersonClassColletction, query);
then initial the static synchronizer with the bindinglist from above
Synchronizers.PersonClassSynchronizer = new SynchronizePersonClass(ref ClassCollections.PersonClassColletction);
Synchronizers.PersonClassSynchronizer.IterationBeforeSleep = 15;
Synchronizers.PersonClassSynchronizer.MaxSleepTime = 10000;
now my big problem that i dont understand is if the ClassCollections.PersonClassCollection has no items on it, then if the synchronizer found new record it doesnt update the ClassCollection.PersonClass then i tried to debug it, the varible "referencedItem" has some items.
but if the classCollection.PersonClass has an item even just 1 before it was passed to the synchronizer there is no problem about it, any moodification in referencedItem will be reflected to ClassCollection.PersonClass and vice versa.
What your thought about that.
Sorry for my bad english and long post.
Thank you
Gilbert
|
|
|
|
|
I don't understand what you're actually asking, but I suspect you don't fully understand what ref does, because the way you used it it's not doing anything.
Parameters passed with ref let the called function modify the variable which was passed by ref. For example:
static void modify(ref int x)
{
x += 10;
}
static void main()
{
int y = 5;
modify(ref y);
Console.WriteLine(y);
}
Since BindingList is a reference type, Some will refer to the same object as was passed in anyway, regardless of ref. And if it had been a value type (which it isn't, but if) then the assignment from some to Some would have copied it anyway. Reference types and value types are something completely separate from and orthogonal to ref.
|
|
|
|
|
I post much more detailed post above, have a look on it. Please ; and what is your thought about it
Thanks
|
|
|
|
|
nice example
Sankarsan Parida
|
|
|
|
|
ok, i think this post is dead
|
|
|
|
|
|
|
Im in need of some help.
I have VS2012. I have created a VSTO Word Template Project.
It has a few dialogs for choices and a Ribbon.
I have used Publish for the solution.
Clicking the template installs the customization, all ok.
I get a new document based on the template and then save that document.
Now a very real scenario is that the user then takes the produced document with them to Another computer and wants to open it there and view the file. Sounds like normal behavior to me.
However, if the template is not present the following message comes:
Microsoft Office Customization Installer
----------------------------------------
Installing Office customization
There was an error during installation.
Name:
From: <path where="" document="" is="">/template.vsto
Downloading file: <path where="" document="" is="">/template.vsto di not succeed.
Why in the World is the customization trying to be loaded when I simply open the document??
Normally if this was not a VSTO-Project, opening a document when the template is not present doesn't give any errors like this, can someone please tell me where I have gone wrong in asuming something like this?
The document consist of text and tables dependant on choices in the dialogs. I have added a ribbon to the template. Not much else.
I simply want the produced document to open to the user if the template is not available.
UPDATED:
Im beginning to suspect I should create an Application Level Addin instead of a Document Level Customization? Even if I do that, and that would solve my issue Im still very curios to why its not possible to open a document based on a VSTO-template without the template, well without the error messages?
|
|
|
|
|