|
If you are going to separate them from your executable, I'd recommend to put them into a resource-file, in a separate assembly.
The end-result would be the same as when you added them to the executable, with the minor diffrence of the overhead of an extra assembly. You'd need to load the thing to access the resources. If they are application-resources that are often used, then they'd be needed anyway. The size won't change, whether they are in a separate file or in the executable.
I do recommend using resource-files; and do use the generated and type-safe access that visual studio provides. Not only does it structure resources, it also makes internationalization easier, since your resources can vary by culture, defaulting to, well, the default culture of your design.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
So , do you think is better do this or not ?
and if yes , where can i read some more information ?
Thank you !
|
|
|
|
|
satc wrote: So , do you think is better do this or not ? I don't think, I provide you with options - you think about what fits you best
Adding it to an external resource only makes sense if you don't require it each time the application runs. If it is required, then it is part of the application footprint and will end up in memory, with or without overhead.
satc wrote: where can i read some more information ? Resources in Desktop Apps (MSDN)[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
As I've said in my first post , this resource contains a lot's of images that are used on different forms or reports.
But of course , not all forms are open every time when the program run.
|
|
|
|
|
A form can have its own resources; in fact, when you create a form in Visual Studio, it will also create a resource-file for that specific form.
If you are using the same image in multiple forms, then it would be preferable to have them in a single place, and not duplicated over all the resource-files.
Since we're talking about a few kilobytes worth of text and pictures, I'd say that the memory-footprint is negligible.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello !
I have a vb.net that use Entity Framework and SQL server database.
On your opinion , is there any way to mimic the role of Windows's Recycle Bin on this application ?
so anything I can do with file on recycle bin , I want to do with records in database ( I mean Delete , Restore , empty recycle bin...).
If yes , what would be the best way ?
Thank you !
|
|
|
|
|
That's relatively easy: You would have to have a field like "Deleted" in every entity which gets set to true when the user deletes an entity first. In all your queries you add a condition "where Deleted=false" unless the user explicitly wants to see the deleted entities. And eventually a user can "empty the recycle bin" where you actually delete the entities which have Deleted=true with the EF method ObjectContext.DeleteObject(entity) (or with direct SQL). Alternatively to "Deleted" being a boolean field you could make it a nullable DateTime field like "DeletedDate" where null means that it's not deleted and otherwise the date of deletion.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Hello !
It seems very easy reading your explanation.
But I don't understand very well the "Empty Recycle bin" idea.
Could you write some code to illustrate this ( I mean , the model may have 100 entities. How can I delete all the object from all entities that have "Deleted=True".
( I'm using DBContext with Database First ).
Thank you !
|
|
|
|
|
There's no way to delete all entities (with "Deleted=true") regardless of their type with a single "command" (unless you create a stored procedure for that in which case the "trouble" would just be moved there).
Options:
1) Via the context (pseudo code):
entities1 = context.Entity1.Where(e => e.Deleted).ToList()
foreach(entity in entities1)
context.DeleteObject(entity)
context.SaveChanges()
Not beautiful because of code repetition.
2) Via the context with reflection:
find all entity types in the context
foreach found entity type
dynamically build a query like above (1) and run the query
foreach found entity
context.DeleteObject(entity)
context.SaveChanges()
No code repetition but considerably more effort.
3) Via direct SQL:
You would have to have a list of all table names in the database (could be obtained via the information schema).
foreach(tableName in tableNames)
context.DataBase.ExecuteSqlCommand("DELETE FROM " + tableName + " WHERE Deleted = True")
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Use your tools to generate code. You have SQL, it can generate a statement.
It sounds as if you are using Sql Server; that means you can query which tables exist in your database. That means you can write a SQL-query that constructs a SQL statement for each entity.
SELECT 'DELETE FROM ' + [TableName] + ' WHERE Deleted = 1' FROM SYS.TABLES Copy and paste the result into Sql Server Management Studio, wrap it in a transaction, and execute*.
*) might wanna check the syntax, did not verify it in a IDE.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have problem with this case :
A Parent Record has the field Deleted=True
All its childs have Deleted=True.
But the sql code produce error , can't delete the Parent because has childs.
|
|
|
|
|
Delete the children before you delete the parent, or use cascading deletes.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
The problem is how to create the sql expression that take care about this detail ?
For example how should I modify your suggested code ?
The idea is to do the deletion with a single query.
(I don't want to use the cascade delete)
|
|
|
|
|
DELETE FROM [ORDERDETAILS] WHERE [DELETE] IS NOT NULL
DELETE FROM [ORDERS] WHERE [Delete] IS NOT NULL
satc wrote: The idea is to do the deletion with a single query. That is technically not possible. You can execute them as a single command that success as fails or a whole. The code would obivously need to be in a transaction.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Ok , but if the database has 100+ tables , if I get one by one the tables master and Childs as you suggest , do you think is a good solution ?
|
|
|
|
|
I am not going to repeat my answer.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi. I have to create an console application, that grabs an xml file via a network share (unc-path)
With the following function I read the xml-file.
Dim filePath As String = "C:\temp\demo.xml"
dsJobStatus.ReadXml(filePath)
dvJobStatus = New DataView(dsJobStatus.Tables(0))
Works fine if the user that runs the exe has access rights to that fileshare; but somtimes I do have to pass username / Password as parameter. Any idea, how I can access the unc-path with passing access credentials?
regards
|
|
|
|
|
net use[^]
Execute the command on a console before executing your code or from your code and wait until it exits.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Appologize if this is childish question but i am in too much confusion.
I learnt first language vb6.0 in 2008 then i was student later and i continue it many years then 2 years ago i shifted to vb.net but in markete there is demand of c#. Many peoples told that c# is better than vb.net that,s why there is no value of vb.net in markete. I still can,t find any job to work in vb.net while i know vb well. Then i learnt C++ and i learnt it well and then i moved to c# and now i can code in c#.
But problem is that i can,t code in c# same as in vb.net. I mean i always prefer vb. In vb i can solve any problem. but in c# i have to search from start and i don,t know why i like vb.net too much. In other words i don,t want to leave vb but markete always force to work in c# and foget vb. If vb is too bad in markete then why microsoft still supports it. Microsoft must close vb because they can,t give good markete to vb. Due to this reasons vb only developers are still poor in markete. They can switch to c# easly but their hearts shall always stick with vb.
I know many languages like vb,c#,java,asp.net,php,mysql,sql etc but my heart always stick with vb.
|
|
|
|
|
|
Message Closed
modified 5-Jan-17 22:39pm.
|
|
|
|
|
But javascript is only scripting language. It can,t create desktop or android applications. I mean it is not equal to vb.net because in vb.net we can develop in desktop,web and cell phone also.
|
|
|
|
|
Hello !
I have a vb.net program , where I want to save on a database several things , and the actual time.
The problem is that the local pc clock may have problems.
Is there any way that if internet connection is present , to get the real date and time ( for my time zone ) from internet and to save to a variable ?
Thank you !
|
|
|
|
|
A Google search will find all you need to know about NTP servers.
|
|
|
|
|
In a VB.net 2010 desktop application, reports obtain their values to execute by users selecting values from the various vb.net controls. In 2 columns where there are date pickers, the default value of the date pickers is to use today's date.
The application passes values from the controls using the following code:
Private Sub dtEnddate_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtEnddate.ValueChanged
Variables.g_strEndDate = dtEnddate.Text
End Sub
Private Sub dtEnddate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dtEnddate.Click
Variables.g_strEndDate = dtEnddate.Text
End Sub
The problem is if the user keeps todays date, and does not change the date, the variables.g_strEndDate never gets a value. These variables I am referring to are in a Public Class Variables and the variable is define as Public Shared g_strEndDate As String.
Thus can you tell me the best way to give this column default values of today's date? What code would you use and where would you place the code?
|
|
|
|