|
Hi all,
Can anyone tell me that how can i fire drop event of richtext box in .net2.0?I mean in my application i need to drag some data from list box and drop into rich text box.
Thanks in advance
Lijo
|
|
|
|
|
To allow drop in the RichTextBox, you have to set RichTextBox's AllowDrop property to true. Then you can handle DragEnter,DragDrop and DragOver Events.
|
|
|
|
|
Hii
everybody,
i am developing window application in c# and .net and i want to know that how to write a join query for update of local database by the content of remote server database!.
Scenario :- Suppose there is one database say softbuyweb at local machine and other database softbuyweb1 at remote server.
now there is table in softbuyweb say product and similarly there is table in softbuyweb1 say product1
now both the table product and product1 in database softbuyweb and softbuyweb1 respectively has same column/field name, datatype and length of datatype.
now i want that in my window form i place one button say "Update" on its click event there should be query which fires and the total content of table product1 at remote server is copied and the content of table product at local machine is updated with that copied content.
i think it is little confusing and also it may be difficult to write single sql query for two different data sorce connection and it might create ambiguity because both connection are establishes in a single block of code.
now , please help me on this topic , and please response as qick as possible!
my database is in sql server 2005.
thanx in advance.
|
|
|
|
|
The easiest way would be to link the SQL Server databases together so you could use an UPDATE FROM statement(Those things are like magic)
Beyond that and using any sort of Database specific synchronization open a cursor, compare records, and update the outdated db.
Need custom software developed? I do C# development and consulting all over the United States.
If you don't ask questions the answers won't stand in your way.
Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: UPDATE FROM
Ennis can you elaborate on this. Is it like the select into shortcut for creating tables?
Wondering if I have missed something all these years?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
UPDATE customer
SET customer.firstName = remoteCustomer.firstName
FROM customer
INNER JOIN remoteCustomer ON
remoteCustomer.id = customer.Id
AND remoteCustomer.GUID <> customer.GUID;
Need custom software developed? I do C# development and consulting all over the United States.
If you don't ask questions the answers won't stand in your way.
Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed.
|
|
|
|
|
Thanks Ennis
Nothing new there, just thought there might have been something quite different. Sometimes I come across something in the forums completely new in a tool I have been using for ages (eq SQL).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hi all
i want to access gmail programatically using c#.
i will just enter my email id & password. if the email id & password is true then the server will give me a response.
but its giving me error the remote server returned an error 403
pls help me
thanks in advance
NameValueCollection nvc = new NameValueCollection();
nvc.Add("accountType", "HOSTED_OR_GOOGLE");
nvc.Add("Email", "dllcheck@gmail.com");
nvc.Add("Passwd", "dllcheck123");
nvc.Add("service", "cl");
nvc.Add("source", "Gulp-CalGulp-1.05");
WebClient client = new WebClient();
byte[] Response = client.UploadValues("http://www.google.com/accounts/ClientLogin",nvc);
string s = Encoding.Default.GetString(Response);
MessageBox.Show(s);
// http://www.google.com/accounts/ClientLogin/accountType=HOSTED_OR_GOOGLE&Email=jondoe@gmail.com&Passwd=north23AZ&service=cl&source=Gulp-CalGulp-1.05
HttpWebRequest webreqAuthenticate = (HttpWebRequest)WebRequest.Create("http://www.google.com/accounts/ClientLogin");
webreqAuthenticate.ContentType = "application/x-www-form-urlencoded";
webreqAuthenticate.Method = "POST";
webreqAuthenticate.ContentLength = 200;
//webreqAuthenticate.Timeout = 6000;
webreqAuthenticate.AllowAutoRedirect = true;
webreqAuthenticate.MaximumAutomaticRedirections = 10;
HttpWebResponse webresAuthenticate = webreqAuthenticate.GetResponse() as HttpWebResponse;
Stream streamResponse = webresAuthenticate.GetResponseStream();
|
|
|
|
|
There are existing solutions for accessing Gmail from C#:
Click[^]
|
|
|
|
|
I am not sure this is the right place for this question but here it is:
Has anyone else had problems with the SqlCeReader.Read() ? Mine doesn't like reading type int from the database and i had to write the query like this (in order to avoid Data conversion failed. [ OLE DB status value (if known) = 2 ]):
SELECT OfficialRegNo, TransponderID FROM BasicAnimal UNION SELECT CAST(FilterObjectType AS nchar), Caption FROM Filter
so, before it was:
SELECT OfficialRegNo, TransponderID FROM BasicAnimal UNION SELECT FilterObjectType, Caption FROM Filter
Anyone knows why?
|
|
|
|
|
You have a data type problem in your database. It would appear that you're trying to put a number is a string field or some other implicit conversion. Did you change a data type somewhere??
|
|
|
|
|
Hi! The datatype in the DB is int and I am only doing a Select query. Only way I could get the Read() method to work was to typecast the int to a nChar. The problem table with an int is FilterObjectType. So I am not trying to insert anything here.
Well, no I haven't changed datatypes anywhere, only this query to the DB.
BTW, I am quering a Sql Server Ce .sdf DB in this case. Not the Express here (was a bit confused when writing prev mess).
This is the only code I have written for this so far is this:
SqlCeConnection conn = new SqlCeConnection();
conn.ConnectionString = "Data Source=todos.sdf;Persist Security Info=False";
SqlCeCommand comm = new SqlCeCommand("SELECT OfficialRegNo, TransponderID FROM BasicAnimal UNION SELECT CAST(FilterObjectType AS nchar), Caption FROM Filter", conn);
conn.Open();
SqlCeDataReader myReader = comm.ExecuteReader();
do
{
Console.WriteLine("\t{0}\t{1}", myReader.GetName(0), myReader.GetName(1));
while (myReader.Read())
Console.WriteLine("\t{0}\t{1}", myReader.GetString(0), myReader.GetString(1));
} while (myReader.NextResult());
myReader.Close();
conn.Close();
|
|
|
|
|
If officialRegNo and filterObjectType are not implicitly convertible you will get this error in all versions of SQL Server.
Need custom software developed? I do C# development and consulting all over the United States.
If you don't ask questions the answers won't stand in your way.
Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed.
|
|
|
|
|
Is there a simple way of sorting a BindingList by the given object element?
A code example of the OrderBy function would be very helpful!
Thank you!
|
|
|
|
|
|
I did, it does seem like an overkill since the BindingList has an OrderBy function. I just don't know how yo use it.
|
|
|
|
|
If you want to support sorting, you have to derive your own class from BindingList. This[^] MSDN article explains why you should do that and how. Please read carefully, especially the "BindingList<t>: What's Missing" section.
|
|
|
|
|
riddick_86 wrote: Please read carefully
Well that's an extremely high expectation round here. Reading carefully is also considered overkill by most our members. Magic is preferred, or when not available a copy paste solution will do.
|
|
|
|
|
Thanks I'll check it out!
|
|
|
|
|
riddick_86 wrote: you have to derive your own class from BindingList
Turns out there was a simple way after all.
listOfObjects = listOfObjects.OrderByDescending(c => c.NameAndSurname).ToList();
That was a list, then I just convert it back to a BindingList.
|
|
|
|
|
Is "listOfObjects" a BindingList to begin with? If it is then you can't use this trick to sort the list as ToList() gives a generic list which cannot be converted to a BindingList, or am I missing something?
Rafique Sheikh
"The truth will set you free but first it will piss you off".
|
|
|
|
|
Rafique Sheikh wrote: Is "listOfObjects" a BindingList to begin with? If it is then you can't use this trick to sort the list as ToList() gives a generic list which cannot be converted to a BindingList, or am I missing something?
Took some digging in our SVN to find that code.
"listOfObjects" is a normal List<>, which I sort as explained in my previous post.
I simply convert it back to a BindingList using a foreach loop, adding each object to the new BindingList one-by-one. I think it has a slight speed penalty, but it works great and I had no better workable solution at the time.
|
|
|
|
|
Thanks for the reply. I see, that's what I thought. Actually the OrderByDesceending and OrderBy, both return an IEnumerableOrdered array which you can iterate over to do the same. I was trying to avoid because of the penalty and also for cleaner code. It is too bad that when you call OrderBy on a BindingList or any other such object the actual list is not ordered but rather you are returned an ordered list. I have the same frustration with this as I have with functions like Remove, Replace for strings etc. Why don't they change the object on which we perform those actions?
Anyway, I think I will have to derive from BindingList<t> and write my own SortableBindingList class!!
Rafique Sheikh
"The truth will set you free but first it will piss you off".
|
|
|
|
|
BindingList<MyClass> b = new BindingList<MyClass>();
b = new BindingList(b.OrderBy( m => m.MyPropertyFromMyClass).ToList()));
|
|
|
|
|