how to use adodc in VB.Net? - vb.net

Another wall in my project. I always thought that connecting to a database using VB.net is also the same on how I did it on VB6. but its totally different in my opinion.
in VB6
we just need to right click>properties>find your file. viola connection established.
then just the fields to your textboxes.
whilst in VB.Net
I tried to add ADODC the property window in VB6, doesn't appear in here since property is the property window in the right side.
one thing, can I use something like this in VB.Net? because its really far simpler than the ones that I see now about OLEDB or MySQL connection string. Its really hard.
If there is no solution to this, maybe you know a site where connecting a DB in my app seems to be easy to understand. thank you.
EDIT I need MS Access for my database..

Check out http://www.vbforums.com/showthread.php?466658.
It's a pretty decent walk through of ADO.NET..

Related

How to change a stored procedure in VBA?

first I have to say: My VB and SQL is limited to the absolute basics. I'm still studying and don't really have a real idea how working with databases works in VB (or in general).
My current task for work is: I've been given a 10 year old program, coded by an ex-employee. This program is written and based on visual studio (a lot of windows forms) and is basically just a database management tool. It's supposed to show the stored data sets and give the user the option to import excel files and add data manually. The program worked pretty good so far, but some of the dropdown menus do not write the selected value into the database, but instead just leave the field empty. I'm supposed to fix that.
Now at first I thought it'd be really easy. Just look at the code of the save-button and check if the insert command contains the correct names of the database fields. After a bit of searching (the code is uncommented and basically a mess) I've found the function that gets called when the save button is clicked. This function takes an SqlDataAdapter and calls the method "InsertCommand" with a stored procedure and the database connection as parameters. Then it adds the different parameters and executes the procedure.
My problem is: Where can I find the stored procedure and how do I change it? I'm guessing there's simply a typo in there for the dropdown fields or something, but since I can't see it and actually don't really have a clue what a stored procedure is, I don't know how to proceed.
Sadly I'm not allowed to post the code, but I hope my explanations are enough for you guys to understand my problem. I don't want you to fix my problem, but rather point me in the right direction - am I completely wrong here, or is my route a good guess?
Thanks in advance, let me know if you need more information!
The Stored Procedure will be in the Database.
Assuming its an MS-SQL database, open Sql Server management studio, find the database, and look under the "Programmability" folder - you should see the stored proc in there.

Vb.net - array, database or sql

I'm making my project for a-level computing and I reached a problem that im not sure how to solve. Im making something similar to a student information management system and I want a way to store a small list of students maybe 5 to 10 preferably in my program and make reference to them from all forms and so that if something is changed on one of the students maybe a piece of information, that these information is carried to the next form. My teacher has very little knowledge on programming and so im kind of stuck, i have no previous experience with databases or sql however if someone is willing to break it down ill be very grateful and ive got a good understanding of arrays. My deadline is the 10th of may so asap please, thanks
- kyle
If you prefer simplicity I would stick to a CSV file or XML. I found a website which an end-to-end tutorial on how to create the XML and add items (students) to it using VB.net as according to your tag. You need only after to read them from the file, but might just as well add new:
http://vb.net-informations.com/xml/how-to-xml-in-vb.net.htm
I would stick with XML (or CSV as preffered) as it is a text file basically so you can see and make changes directly if needed.

Display a DAO table in a form

I'm upgrading an old VB6 application to VB.NET that uses DAO to connect to an Access database. I know that this is a hopelessly outdated technology, but considering the amount of work changing to ADO, I've decided to stay with DAO, despite the frustration trying to find documentation.
My problem is that I'd like to have a DataGridView reflect a table from the database. Of course I could make my own routine manually setting the columns and fill the DataGridView, but if it is a way, I'd like to use the DataSource property or some other built-in function. I found a forum post that looked promising, but unfortunately I couldn't find the attachment that was referred to.
Also, if there are other controls better suited for this than the DataGridView, please let me know.
Thanks
DAO documentation isn't hard to find. Install VB6 and the Microsoft Developer Network (a disk was bundled with VB6). Go into the VB6 IDE, view your code, put the cursor on a DAO keyword, press F1. Presto - helpful documentation! If you prefer an online reference, the DAO documentation from Access 2007 should meet your needs very well.
So you want to bind a DataGridViewTable to a DAO table? Nice idea, but it's a big ask. Did the VB6 app use data-binding?
If it did, you're going to have a hard time migrating that to VB.Net. Consider shifting to ADO.Net in the VB.Net replacement.
If it didn't, you might be able to use DAO from VB.Net via COM and you might find that the DAO-related VB6 can be ported to DAO-related VB.Net without much effort. I don't know.
One option would be to use a method found in Code Complete. Put a nice, clean layer between the VB.NET user interface and the legacy data access code (your DAO code). The layer would take the data fetched via DAO and transfer it into a DataTable object. Then, you send the DataTable to the UI and use it as the .DataSource property of the DataGridView.
Honestly, however, since this involves writing code for each DAO function that returns data for you to display, I would just refactor your data access routines into ADO.NET. Since DAO is so, so, so old, in my opinion it would be irresponsible to be creating a "new" application and using such outdated technology, even though it technically can "work".

Generating and printing a form in Visual Basic 2010 Express

I am primarily a web developer, mostly working with PHP, MySQL, and JavaScript. I was recently contacted by a local Sheriff's Office (small town word of mouth, nerds are always needed) to digitize a 4 page monstrosity of a form... because nobody could read the handwriting of the deputies.
The catch here is that this is a small town department and, while they are fancy enough to carry computers in the field, they are not connected to the Internet. Visual Basic was the first solution that came to mind and I have been scrambling to learn the basics. I am confident in my ability to organize the content of the form and perform any necessary validation but I am unsure where to begin in terms of storing each report locally (database) and printing the end result.
Another matter that makes things complicated is the fact that they want the end result to look exactly the same as the original form, only typed instead of hand written.
So, to sum things up, here are the questions I have:
There seem to be several options for databases in VB 2010 Express. What is the best option for LOCAL storage of records?
It looks as though the best way to format the form the exact way they want it to look with populated data would be to create a form within the application with just this content on it. Is this the best solution or might there be a better way - possibly outputting to another file? And if the data is put on another form, how would I go about printing it?
Many thanks!
The word "best" is of course subjective, so instead I'll give you some pros and cons for a database.
SQL Server Express is a really awesome database to work with that acts almost exactly like the big paid version. Some high-level things like replication and encryption aren't supported but you don't have a need for that probably. I've built many websites that target it with zero performance problems. The downside of SQL Server Express is that you need to install it on every machine and it pretty much needs to be running all the time. It doesn't "weigh" a whole lot but its still going to be running in the background 24/7. If you create an installer from within Visual Studio/VB Express (which you should) you can check it as a prerequisite and the installer will pretty much take care of it for you. As a major security target you are opening a potential for security issues which you should be aware of.
SQLite would another great choice, there's some great .Net wrappers available. If you're used to using SQL Server or MySql you might find SQLite limiting but you get used to it. SQLite doesn't have a "database engine" and its goal is to be a very lightweight open source SQL database system.
The third option that I'd recommend is just writing to an XML file. Simple, no engine, no tables, no third-party whatever, just raw text that anyone can parse if something breaks. EDIT And VB.Net has some wonderful built-in XML syntactic things such as XML literals:
Dim MyXml = <Person>
<FirstName><%= txtFirstName.Text %></FirstName>
<LastName><%= txtLastName.Text %></LastName>
</Person>
For the form generation, I'd recommend using something like iTextSharp. (Free but make sure you check that the license matches yours.) Take their actual PDF Form (or create a PDF of theirs), use Acrobat or something similar to turn it into a "PDF Form" and then just use iTextSharp to fill in the form. There's a bunch of support on this site if you've got any questions about it.

DB-side encryption via NHibernate

We're looking to encrypt a field using DB-side encryption via NHibernate (most examples we've come across are app-side, which is not what we would like). The issue has been raised a couple of times, but no answers yet it seems.
On SQL Server 2005, for instance, and forgetting key-related issues for now, this means INSERTing EncryptByKey(Key_GUID(MyKey), MyValueToEncrypt) and SELECTing DecryptByKey(MyEncryptedField). The property might be a string, whereas the field has to be a varbinary.
We've vaguely got somewhere - using upper() and lower() instead of encryption functions - by combining paired properties, one mapped with a custom user type and the other with a formula attribute.
However if anyone has any ideas on how to do this in a nicer way, we'd be most grateful for a few pointers :o)
Posted outline of nasty hack on the NHibernate forum
There is a project on SourceForge, MindLib, that has useful NHibernate utility functions and libraries. One of those is an EncryptedString library which allows you to store an encrypted string. Unfortunately, this is not doing it on the server side, as you originally requested.
I've been looking for something similar. The only thing I could come up with is to create a User Function in SQL Server to encrypt the string. Something like this.
MindLib EncryptedString
thanks for the feedback! We're keeping the MindLib approach as a last resort because it effectively displaces data ownership from the DB to the app. As far as we can tell, TDE-enabled DBs (say SQL Server 2008 or Oracle 10.2) make the problem go away, but not all our customers are willing to splash out on upgrades ;o)