Storing information in a Visual Basic form [closed] - vb.net

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
Okay so im writing a program for my vegetarian girlfriend that does two things from the main menu. 1: add foods with attributes like name, iron content, protein, sodium etc. 2: use the foods that have already been stored and use them to make a balanced meal. What im having trouble with is, how do i save the attributes when storing the foods ? i have knowledge with c++ so i understand how classes work and was wondering if there is something similar in Visual Basic. I would also like to know how to save the foods so that they can be used again when the program is closed and then reopened. Thanks in advance. I am VB noob but i do have some c++ knowledge.

Well, you'll need the data to be persistant, so that, when she closes and reopens the application, previosly entered data is still there.
The best and simplest approach to do that, IMHO, is to use a database, since, databases are great at just that - storing data. However, that will add some complexity to your application. I would recomend to take a look at SQLite, using a .net driver. That will give you all the benifits of a database, and will take away at least some of the complexity.

Yes, VB.net have advance OOP capability. Just instantiate the class and play with it.
class Food
public dim food_name as string
public sub save()
'wirte code to save the class data
end sub
end class
'Use it as
Dim food as Food
food =new Food()
food.save()
To store the data u can use Database like Acess/Sql server or simply u can store them in plain text and xml.
in my suggestion use XML to store the data

Related

SQL Server 2005 nested views - strategy for unentaglement? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a reporting web application that graphs information based on aggregations done in a series of nested sql views (3 levels deep). The last nested view is called from a stored procedure within the entity framework code. The performance penalty of this has begun to take its toll, as it struggles to get data and times out:
In Sql profiler there's 360,000+ reads and CPU # 28313. In addition, I can't even open the third level view in SQL without timing out.
The first view simply gathers data from the several tables and aggregates. The second performs calculations on this data such as date differences, time zone adjustments, and averages. The third finalizing these calculations and presents a summary of the required data. The third view is the one I query from.
What is a good strategy for untangling nested views, in general? Specifically if you have calculations that need to be done in SQL server, but can only be done once data has been combined into a certain level, what's a better strategy than nested views?
Thanks for any help you can provide!
You can include any view as a subquery, however, I doubt that in itself will help performance in this case. It will enable you to look at parts of the views and possibly put any shared parts into table variables or temporary tables.
If you could share more information, that might help.
I advise you:
inline those views, so you've got it all in front of you
cut it down, bit by bit, to see where the (uncompiled!!) performance issues are.
fix the performance issues
hope that the performance issues are in the same place once it is compiled.

Storing a result set in a SQL Server database? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm looking for a way to store a result set in my SQL Server database so it's faster to retrieve, if possible. The reason I want to do this is that I need the information quite frequently, but the data rarely changes so I believe it will improve my database performance a lot.
The only thing I was able to find was indexed views, which doesn't work for me since my query doesn't qualify for that kind of view.
My result set is derived from several sql queries, that will increase in time.
My backup solution is to have the program using the database to store it's own copy, so I can skip calling the database. But this will make my system more complex. I would rather have all my data calls in the database so it's easier to keep track of things.
Do any of you know a way store result sets on a SQL Server database?
I need the information quite frequently, but the data rarely changes
If the data is going to rarely change, then why not just use a SSI file based on the data in the database. You can always recreate this text file whenever the data changes.
When I did web stuff we served up all the data for all the web pages directly from database queries. We decided to change our model to use SSI files for all the database items that rarely changed. We built a "File Recreation" routine inside the backend admin that would automatically build and overwrite the SSI file when ever the customer changed one of those "rarely" changed database items.
This boosted performance on our servers, cut down on server round trips and spead up the display time. Truly a win-win.

Merge conditions to one place [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
There are two functions: one returns records of workers who have certain tasks to work with and the other one returns the tasks for a particular worker. These two functions have cursors with the same conditions in the WHERE clause.
My question is, how can I define these conditions in a single place? Then my code won't break DRY principle.
Thanks in advance!
P.S.: I wouldn't like to use REF CURSORS because they are unreliable.
I think a sensible rule of thumb with DRY (Don't repeat yourself) is triangulation: if the same logic exists in three places it is worth the effort of extracting it into its own module. But don't bother if it only exists in two places.
However, you aren't really repeating yourself, are you? What you have is two different queries returning two different resultsets (one is WORKERS the other is TASKS) which just happen to have some bits of their WHERE clauses in common. That's not proper repetition.
If you try to root out everything single instance where two lines of code do the same thing you will end up with a horribly unreadable and unmaintainable programs. Remember that DRY was formulated by Andy Hunt and Dave Thomas, who call themselves Pragmatic Programmers for a very good reason: apply the principle sensibly and understand why you're doing it, rather than blindly following dogma.
Addressing your reservations about REF CURSORs, why do you think they are unreliable? I've never had any problems with them. What might well give you grief is using dynamic SQL to populate ref cursors. But that's a function of trying to remove imaginary duplication, and is nothing to do with the use of cursor variables as such.

Have you ever done SQL injection? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I want to know if you have ever performed injection on a website using SQL injection for ethical hacking.
What tricks/techniques have you have used (especially mysql)?
I've used the standard trick on login forms:
user: admin
pass: ' OR '1'='1
Not directly, but sometimes I do LIKE searches with wildcards (%) even though the search page does not say it supports them.
If you intend to perform ethical hacking or penetration testing of applications using MySQL, you'll find the OWASP Testing Guide, specifically the section on MySQL to be of immense value, apart from the generic Testing Guide for SQL injection.
Note that this does not make any assumptions about the framework or langauge in use - PHP, Java (including Java EE, Spring etc.), so it is pretty generic in how SQL injection may be attempted against an application. The actual techniques involved in getting the user inputs to the database access layer of the application, indeed will vary from one application to another. Applications that parse HTTP requests, will of course, require all inputs (URL parameters, name-value pairs in the POST body, HTTP headers) to be suspect. Having a different source of input (say XML or JSON instead of simple HTTP requests) will require you to feed in SQL in appropriate manner that will be understood by the application's parsers, eventually resulting in transportation of SQL to the layer where database queries are executed.
Nice infomation about techniqs for
Example :
statement = "SELECT * FROM users WHERE name = '" + userName + "';"
pass userName = ' or '1'='1
SELECT * FROM users WHERE name = '' OR '1'='1';
SQL injection
Type of it
1.2 Incorrect type handling
1.3 Vulnerabilities inside the database server
1.4 Blind SQL injection
1.4.1 Conditional responses
1.4.2 Conditional errors
1.4.3 Time delays
You just remimded this, I hope you'll find it fun:
http://xkcd.com/327/ ;)
Yes I have used the basic methods like everyone else, but always on my own websites
' OR '1'='1
I even joined a site where you can learn the basics of hacking in a website, they have put up a serie of website specially made to show the vulnerability of the website (of course you are not shown how to do it but you have to find it out for yourself). And no I feel no guilt whatsoever as I do not use it to harm other peoples website but only myne.

FOR XML AUTO in stored procedure [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
will FOR XML AUTO queries in stored procedures and using ExecuteXmlReader to retreive data to set business objects cause any performance hit?
I don't know about performance, but I have started doing things this way in order to take advantage of serialization, so I can pass BLL types as generics directly to the DAL for filling, and I like it a lot. It bypasses the Linq or typed DataSets, and uses a lot less code, whether machine-generated or not. As for performance, the best thing to do is run your own tests.
Update: If you're going to use FOR XML to serialize to BLL objects, don't use auto, use PATH, and specify the name of the root, otherwise it will use <row/> as the root element.
It surely affects the performance if the amount of data you are going to retrieve is relatively higher (The XML formatting is bigger than TDS rowset). I don't have the exact statistics with me. But tou can easily profile your queries with and without XML AUTO and find the facts. But XML AUTO surely takes much time than normal SQL queries.
I would say its preferrable to convert your recordsets to XML format in your application code than doing it in sql server.
EDIT:
T-SQL commands vs. XML AUTO in SQL Server - this article explains and gives the comparison between XML auto and normal T-SQL queries, have a look at this.
Author concluded that "It seem to be consistent that the T-SQL query is performing better than the rest. The XML query FOR XML AUTO is using more than eight times more CPU but the same amount of I/O. The complex XML commands are issuing more than 80 times (!) more reads than the T-SQL command, also many writes and above six times the CPU."