First, please don't ask me why I need to do this. Unless you can tell me how to convert a TFDDataset directly to a _RecordSet, please, don't ask. :-)
So, this is my question:
Give a TFDDataset, how can I convert that dataset into a TADODataset?
The TFDDataMove component will only move to a FireDac dataset, not to anything else.
What strategy would you recommend? Brute force (iterate over fields and records...) is the only thing I can think of, but perhaps I'm missing some easier or better way.
Thanks.
OK, I ported it to Delphi XE4 and also started adding bookmark support so you can hook it with a TADODataSet and use TDataSource and data-aware controls. There still seems to be a little bug somewhere which causes the dbgrid raise a "grid index out of range" error if you navigate to the last record immediately after switching to the ADO dataset. Anyway, here's what I have.
Merry Christmas, Nick!
ADORecordSet.pas
Test project:
Project1.dpr, Unit1.pas, Unit1.dfm
Related
I have a table called settings, when I would change or enter data into the form it did not change the data in the table. In addition on form an image upload file is not running, There may be the wrong code below.
(Solved by me)
Maybe someone can help me Related to this.
What you are doing here is tottaly in secure and your data can be hacked / manipulate really fast.
Why dont you use a framework like codeignighter there are about 100 easy frameworks that will help you manage database a lot easyer.
Are you sure that you are updating the wrond ID? where id = 1, seems to be not dynamic.
Please post your error http://www.w3schools.com/php/func_mysql_error.asp
I know it is not so related to your question, but you should see these light frameworks:
http://kohanaframework.org/
https://github.com/ElbertF/Swiftlet
http://ellislab.com/codeigniter
You're not checking the return status of of your query, so if it's not working you wouldn't know. Do this:
mysql_query("UPDATE settings SET site='$name',keywords='$keys',descrp='$desc',email='$email',fbpage='$fbpage',twitter='$twitter',gplus='$gplus',disclaimer='$disclaimer',template='$template' WHERE id=1")
or die(mysql_error());
Note: mysql_*() is deprecated: you shouldn't use it. Use mysqli_*() or PDO instead.
Also: You are susceptible to an SQL Injection attack. You should escape your input variables with mysql_real_escape_string() (or the equivalent if you switch to mysqli), or consider moving to prepared statements.
Trying to find help for this problem has taken me to a whole new one: complete lack of ressources, books and samples vor MVC 4 in VB.NET. I am having to choose between learn by experience (and the associated feeling of banging your head against a wall) or give it up and move to C# alltogether.
No company should ship a product if they are not willing to give it the same support as its sibling pruduct. They should drop VB for MVC completely or give us the means to learn it.
With that out of the way, here's my question. This line:
#Html.EditorFor(Function(x) x.UsersData(temp).Roles(Role))
Is a nice line of code. Works wonders. But How can I add a class to it, so I can change the style on my css files?
Well, it seems that this should do the trick:
#Html.EditorFor(Function(x) x.UsersData(temp).Roles(Role), New With {.class = "users-manage-check-box"})
But guess what, it doesn't. Ever. The result is the same.
What is wrong and how can I fix it?
And to be completely honest, I did come up with a solution. One that makes me feel dirty.
Looking at the output from that code, i see that the boxes classes are "check-box".
So what I've been doing is this:
#html.Raw(Html.EditorFor(Function(x) x.UsersData(temp).Roles(Role), New With {.class = "users-manage-textbox"}).ToHtmlString.Replace("check-box", "user-manage-checkbox"))
This feels wrong. So wrong. And not only is it a sad piece of code, it introduces security risks, which I'll have to fix before my solution is out of the development phase.
Any clues on why the additional view data is not working as it should? Am I getting something wrong? Am I asking too much?
Thanks a lot!
I don't think EditorFor allows that. So you need to create a custom editor template yourself.
You can read more about creating custom templates in this blog post
Update:
Take a look at the answer for this issue from http://aspnetwebstack.codeplex.com/
This behavior is by design.
The overload that you are calling accepts an object parameter called
additionalViewData (http://msdn.microsoft.com/en-us/library/ff406462).
The default implementation of EditorFor ignores this value. You would
have to write a custom editor template to be able to access that
information.
Seems my appreciation for the Entity Framework is taking a serious hit. The "MS almost got it right, but they just missed it because of something L-A-M-E" thought is coming up. Until today everything has been fine. For some unknown reason, it won't compile anymore with Error 2048. I've read up on this and I've seen how you need to map all three operations. Why is this even necessary? What I if I don't need a delete function and only need insert and update? I tried mapping a dummy SP to my delete function. If that fixes my problem, however cheezy, fine. Only problem is, it just created more problems.
Here's what I have. I'm writing a simple newsletter app in MVC. I have entities for a publication, issue and article all generated from my DB (SQL 08). I set up the the relationships in my DB and they translated fine to my EDMX. I made some SPs to insert and update my issues and article. I added them to the EDMX and mapped them accordingly. I don't need a delete function for any of them and I don't need anything for the publication entity. Why is the compiler forcing me to map all functions? IMO, this a MAJOR, MAJOR PROBLEM with EF4 and I can't believe MS would release it with this kind of crap coming up.
The other strange issue is I've tried mapping sp's to entities in another project and configured with only insert and update and they compile fine. Why is the compiler inconsistent?
I would rather not resort to having to use the Imported Functions. Is that my only option? If that's the case it eliminates the ability to the SaveChanges method. Come On MS!!! Fix this!!!!!!!
After much digging and side by side text comparison, I think I have found the solution.
The SP in question was set up like
CREATE PROCEDURE updateArticle
(
#ArticleID INT,
#Content TEXT
)
where it should have been something like
CREATE PROCEDURE updateArticle
(
#ArticleID INT,
#IssueID INT,
#Content TEXT
)
Now, I still don't know why EF4 even requires this since I'm not updating the issueid and the error message lends little help in diagnosing the problem. My SP doesn't even use the IssueID, but EF needs it regardless. Hopefully this will help someone down the road. MS still could do a better job regarding the need for this.
got an ADOQuery that has OnNewRecord event.
on the procedure i try to add data automaticaly to another table. the data is a few rows that are needed and handled in clientDataSet in case of cancellation.
at the loc
OtherAdoQuery.insert;
I get error that ADOQuery failed to insert null into a non null field. I am in insert mode, however I NEVER ASKED DELPHI TO POST! i dont find why it posts.
Edit: could you help me find a hint on this problem?
some more clarification:
at
ADOQuery.onNewRecord();
begin
CliendDataSet.insert; //here goes to post for ADOQueryPost. where ClientDataSet was in Browse State
end;
Edit:
this bug does not make sense! look at the stack trace:
beforePost
newRecord
myFunc
where myFunc does cause NewRecord with the Insert.
I'm not too familiar with TAdoQuery, but I know how to track down an error like this. First, if you don't already have it set, go into Project Options and turn on Use Debug DCUs under the Compile tab, then run a full build and run it. When you get that exception report in the debugger, hit Break and you should end up inside the code for the TAdoQuery or one of its sub-objects. Try examining the call stack. If you look up a few calls you'll probably find something that you did is calling something else that's calling Post. Follow the stack trace back until you reach your code and you'll get an idea of what's going on, and if you analyze it a little you should find some way to prevent the problem.
Having said that, let me make a quick guess as to the cause of your problem: When you call Insert on a dataset, if the dataset is already in appending mode because you previously called Insert or Append and didn't follow up with a Post, it will call Post itself before setting up a new row for you to work on. Maybe this is what's happening to you?
the answer was from a connection between the tables.
the ADOQuery.dataSource was set the DataSet of the ClientDataSet.
this mad so much damage, and no hint by the delphi.
I have a ListView:TListview on my form ,and, I add many values(approximately 25k TListViewItem) ,which works quite fast,but when I call Listview.Clear,the program freezes.I checked it with debugger,it won't step that line.
My question is: how do I solve my problem? If creating so many items in less than a second is possible,why deleting them takes forever(I waited over 5 minutes)?
Have you tried enclosing your call to Clear in a BeginUpdate/EndUpdate block:
listview.Items.BeginUpdate;
try
listview.Items.Clear;
finally
listview.Items.EndUpdate;
end;
Adding/Removing items in a listview (or various other controls, e.g. listbox) triggers a GUI update of the control for each and every item that is added/removed. For a listview in particular, this can be quite expensive and for 25,000 items the overhead would be significant.
Admittedly 5 minutes does sound excessive, but this would be the first thing I would try.
The first thing I'd try is wrap your call to Clear with BeginUpdate/EndUpdate.
ListView1.Items.BeginUpdate;
ListView1.Clear;
ListView1.Items.EndUpdate;
Do you have any events attached to the ListView, and are they firing as the list is being cleared?
as the others noted a BeginUpdate .... EndUpdate will greatly increase performance, however I would really suggest you move your code to use VirtualTreeView. It's a hybrit tree/ListView which will add up to 1m nodes in less than a second (actually that depends on the processor, but you get the idea).
It's a bit harder to learn in the beginning but once you get used to it you'll find it "easy" to work with. I personally whenever I need many rows in a ListView or TreeView look no further than VirtualTreeView. Oh, and forgot to mention that on top of it, it's free. Try it from : http://soft-gems.net/
John, it should not be longer to clear than to add the 25k items.
I wonder if you load it while it is not visible (automatically disabling updates), but clear it when it is visible where each item deletion triggers an update.
I don't know whether I should delete this question or not,I believe it's not going to be in any use to anyone else,but I prefer to keep it for awhile at least for you,who answered.
The problem was that I used a component inheriting from TListView,I thought It wouldn't be a problem so I decided to say TListView,but I was wrong.
I upvoted all your answers, please excuse my ignorance - I'm new.