|
You need to catch the errors and persist the failed mail details. When it executes next time, read from this persisted data and try to resend.
|
|
|
|
|
but my senior talked an=bt some thing emi or dmi whats that?,
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
I'm using the following code to roundtrip a value between one Int64 var and two In32 vars.
public static Int64 Int64FromPersistentIDs(int highID, int lowID)
{
return (((Int64)highID << 32) + (Int64)lowID);
}
public static void PersistentIDsFromInt64(Int64 longID, ref int highID, ref int lowID)
{
lowID = (int)(longID & 0xFFFFFFFF);
highID = (int)((longID >> 32) & 0xFFFFFFFF);
}
This code roundtrips well when highID is positive, and when highID is negative and 9 digits, but it fails as soon as highID is negative and 10 digits - the highID comes back as off by one (one too large).
What am I doing wrong here?
|
|
|
|
|
int64 is up to 19 digits and
Max/Min value is +/-9,223,372,036,854,775,808 ,
where int32 is only 10 and
Max/Min value is +/-2,147,483,647
what your'e doing is spilling bits off by (int)(longID & 0xFFFFFFFF);
int is Int32 and not int64
Have Fun
Never forget it
|
|
|
|
|
Actually, that wasn't it. I think.
I went back and changed all Int64 to UInt64, and it stopped failing in all cases.
|
|
|
|
|
Can you give an example that does not work?
Using your methods, I plugged in some numbers and, round trip, it works just fine (even without changing the types to unsigned).
static void Main(string[] args)
{
int highID = -1234567890;
int lowID = 123456789;
Console.WriteLine("Build 64-bit ID:");
long longID = Int64FromPersistentIDs(highID, lowID);
Console.WriteLine("highID: ({0,20})", highID);
Console.WriteLine(" lowID: ({0,20})", lowID);
Console.WriteLine("longID: ({0,20})", longID);
Console.WriteLine("\nExtract-32 bit IDs:");
PersistentIDsFromInt64(longID, ref highID, ref lowID);
Console.WriteLine("longID: ({0,20})", longID);
Console.WriteLine("highID: ({0,20})", highID);
Console.WriteLine(" lowID: ({0,20})", lowID);
}
public static Int64 Int64FromPersistentIDs(int highID, int lowID)
{
return (((Int64)highID << 32) + (Int64)lowID);
}
public static void PersistentIDsFromInt64(Int64 longID, ref int highID, ref int lowID)
{
lowID = (int)(longID & 0xFFFFFFFF);
highID = (int)((longID >> 32) & 0xFFFFFFFF);
}
Outputs:
Build 64-bit ID:
highID: ( -1234567890)
lowID: ( 123456789)
longID: (-5302428712118268651)
Extract-32 bit IDs:
longID: (-5302428712118268651)
highID: ( -1234567890)
lowID: ( 123456789)
|
|
|
|
|
Sure:
The following High / Low combination: -1173074781 / -1181223073
was round-tripping back as -1173074782 / -1181223073
(note the High Order output is one more than the input.)
I determined that that code which builds the 64bit INT was the culprit, here's why. These IDs are passed to me by an application that actually stores a 64 bit number in it's XML database. However, instead of passing me the 64bit number, it passes me two 32 bit numbers.
I looked inside the database for the record I was querying, and the 64bit number stored there is: BA144CA3B997F75F
But my code (return (((Int64)highID << 32) + (Int64)lowID) ) was returning BA144CA2B997F75F (note the difference at the 8th digit - the 2 should be a three)
So I was getting a bad 64 bit number from my code. I changed my units to UInt64, and my code started returning a 64 bit number which matched that number stored in the database.
I don't know exactly why it was failing, but I could tell it was a "size" issue, because some inputs were returning the correct 64 bit numbers (as validated in the database), and some were not.
|
|
|
|
|
I'm a chinese learner, Use the MatrixClass.cs to want to get my resualts, but can not...
Can you use my arrA,arrB and Matrix to get the resualt? help me, please!
double[,] arrA = { { 99.07, 70, 1.6, 1.1, 0, 0, 25, 0 }, { 0.31, 15.7, 0.45, 0.3, 0, 0, 1.34, 0 }, { 0.05, 0.2, 30.52, 54.5, 0.09, 0, 50, 0 }, { 0.05, 0.2, 21.32, 2.1, 0.08, 0, 0, 0 }, { 0.23, 13, 0, 0, 42.77, 58.2, 0, 72.28 }, { 0, 0, 0, 0, 42.77, 0, 0, 0 }, { 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, -67.2, 0.8, }, { 0, 0, 0, 0, 1.71, 2.3, 0.8, 69.96 } }; ; //array of coefficients
double[,] arrB = { { 72 * 100 }, { 1.2 * 100 }, { 8.3 * 100 }, { 4 * 100 }, { 14.0 * 100 }, { 0.042 * 100 }, { 0 }, { 0 } };
|
|
|
|
|
WHAT????
present the problem/Question, beacuse i can't see it
Have Fun
Never forget it
|
|
|
|
|
|
sgncdc wrote: I'm a chinese learner, Use the MatrixClass.cs to want to get my resualts, but can not...
Why can't you? What is keeping you from getting the result? What do you do to try to get the result, and what happens when you do that? Do you get any error message?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
sgncdc wrote: MatrixClass.cs
What is this and why do you expect us to know about it ? If it's in an article, ask the author in the forum under the article.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
I read data from a database to dataset and diplay it in a datagrid.
Now I want to update database from xml file
First I read update xml file: dataset.ReadXml(fileName);
Now I update database with dataset:
SqlTransaction trans=null;
try
{
string strcnn="Data Source=.;Database=HaSTC;Integrated Security=SSPI";
SqlConnection cnn=new SqlConnection(strcnn);
cnn.Open();
string fileName=@"D:\xml\STS_Stocksinfo.xml";
DataSet ds= new DataSet();
ds=DataReadingFromXMLFile(fileName);
SqlDataAdapter adapter=new SqlDataAdapter("select *from stocks_info",cnn);
trans=cnn.BeginTransaction();
SqlCommandBuilder builder=new SqlCommandBuilder(adapter);
adapter.SelectCommand.Transaction=trans;
adapter.Update(ds,"stocks_info");
trans.Commit();
cnn.Close();
}
catch
{
if(trans!=null)
trans.Rollback();
}
But when I execute it. It has a notice: "Update unable to find TableMapping['stocks_info'] or Table['stocks_info']".
So I can't update my database.
What is the problem? Please tell me clearly
Truong Thanh Dien HUFLIT, VietNam
|
|
|
|
|
is the table name Correct??
The Table name in DataBases are Case Senstive
Have Fun
Never forget it
|
|
|
|
|
Thanks you for your answer
But when I change table name from "stocks_info" to "STOCKS_INFO", nothing change. My program still have a same notice
What is my problem?
Truong Thanh Dien HUFLIT, Vietnam
|
|
|
|
|
Hi,
I can successfully insert data into database fields.
I can also upload file into database field.
However, i wish to combine both in one operation i.e. inserting data into fields as well as uploading file in to another field.
Example of fields: Name, Address, Story (where story is a field to store uploaded file)
Can someone help please
|
|
|
|
|
|
You cannot directly store the file.....but instead you can store the data of the file...let me know the exact data of your file.
Systems Analyst
|
|
|
|
|
Hi,
I want to copy Dictionary Object of one classA to Dictionary Object of classB. The strctures of classA and classB are same. Is it possible to do it? If yes, how?
Here's something I am trying....
classA
{
public string str;
}
classB
{
public string str;
}
classC
{
Dictionary<string, classA> dictA = new Dictionary<string, classA>();
Dictionary<string, classB> dictB = new Dictionary<string, classB>(); //Thanks for poiting out Navaneeth
public someMethod()
{
//some code
dictB = dictA; // HOW TO DO THIS??? I WANT TO COPY (NOT ADD / APPEND) THE ENTIRE COLLECTION
//some code
}
//Other code
}
Cheers,
Vaibhav
<div class="ForumMod">modified on Wednesday, July 23, 2008 11:21 PM</div>
|
|
|
|
|
vaibhav.jape@gmail.com wrote: Dictionary<string, classB> dictB = new Dictionary<string, classA>();
This is invalid and won't compile. Second dictionary can contain key as string and value as any "ClassB " type. How you are expecting "ClassA " type to be copied to there ?
|
|
|
|
|
Dictionary<string, classB> dictB = new Dictionary<string, classA>();
This is invalid and won't compile. Second dictionary can contain key as string and value as any "ClassB" type. How you are expecting "ClassA" type to be copied to there ?
-------------------------------------------------
Thanks for pointing out that Navaneeth, but frankly i was just a type mistake. I am sorry for that!!!
Can you help me now????
Rgds
Vaibhav
|
|
|
|
|
In the Dictionary class you have an overloaded constructor to which you can pass you current Dictionary object and create a copy of the same.
<br />
Dictionary<string, string> abc= new Dictionary<string, string>();<br />
abc.Add("abc","def");<br />
abc.Add("ghi","xyz");<br />
<br />
<br />
Dictionary<string, string> copy = new Dictionary<string, string>(abc);
modified on Wednesday, July 23, 2008 11:18 PM
|
|
|
|
|
You have to relate classA and classB in some way - the easiest being inheritance, or implementing the same interface.
Inheritance - Have a common base class for these two classes, say ClassAlpha.
Then it should become
// create new Dictionary
Dictionary<string,ClassAlpha> dictA = new Dictionary<string,ClassAlpha>();
// Fill this one
// ...
// Create a copy
Dictionary<string,ClassAlpha> dictB = new Dictionary<string,ClassAlpha>(dictA);
|
|
|
|
|
vaibhav.jape@gmail.com wrote: dictB = dictA
This don't work. You want to copy all the ClassA objects value to ClassB object and store in dictB , right ?
class ClassA
{
public string str = string.Empty;
public ClassA(string str) {
this.str = str;
}
}
class ClassB
{
public string str = string.Empty;
public ClassB(string str) {
this.str = str;
}
} To copy values, you can use
Dictionary<string, ClassA> dictA = new Dictionary<string, ClassA>();
dictA.Add("X", new ClassA("First"));
dictA.Add("Y", new ClassA("Second"));
dictA.Add("Z", new ClassA("Third"));
Dictionary<string, ClassB> dictB = new Dictionary<string, ClassB>(dictA.Count);
foreach (KeyValuePair<string, ClassA> pair in dictA) {
dictB.Add(pair.Key, new ClassB(pair.Value.str));
}
|
|
|
|
|
Hello folks.
It's been a while since I've managed to paint myself into a corner - but have no fear - I have not lost my talent for getting in over my head!
This time I am working with reflection and trying to access different classes generically . But I have run into a problem trying to get some information out of an object when the object's class isn't known until runtime:
public void GetDataFromStaticClassX(string MethodToCall, object[]MethodParms)
{
private const BindingFlags StaticMethodBindings = BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod;
private const BindingFlags InstancePropertyBindings = BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty;
private const BindingFlags InstanceMethodBindings = BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;
object returnedInfo = typeof(X).InvokeMember(MethodToCall, StaticMethodBindings, null, null, MethodParms);
That works: the proper method is called and the result is put in returnedInfo . However, the result could be any of a number of different classes, depending on the value of MethodToCall . The only thing I now for sure about the contents of returnedInfo is that it will implement IEnumerable .
int returnedInfoCount = (int)returnedInfo.GetType().InvokeMember("Count", InstancePropertyBindings, null, returnedInfo , null);
That works too. I can see the proper value being assigned to returnedInfoCount .
Now comes the kicker: I want to access the first entry in returnedInfo . I tried this
object myData = returnedInfo.GetType().InvokeMember("Item", InstanceMethodBindings, null, returnedInfo, new object[] {0});
No luck. The exception says method Item is not found.
returnedInfo.GetType().InvokeMember("MoveNext", InstanceMethodBindings, null, returnedInfo, null);
object myData = returnedInfo.GetType().InvokeMember("Current", InstanceMethodBindings, null, returnedInfo, null);
Also dies - "MoveNext" is not found.
Does anyone have any ideas of how I can get at the first entry in returnedInfo ?
Many thanks if you are kind enough to look into this.
Even more if you have a suggestion/solution/idea/words of encouragement...
edit: small error in the example code
Clive Pottinger
Victoria, BC
modified on Wednesday, July 23, 2008 6:54 PM
|
|
|
|
|