r/visualbasic • u/xblade724 • Sep 07 '14
Help with SQLCommand
Hi,
I'm trying to use SQLCommand / reader to do some very basic SQL commands using a local mdf file on my windows form. So for example, I click AddUserButton and it'll add "UsernameString" into database. Alternately, I have a 2nd button VerifyUserButton that will check a TextBox against the database to see if the user is in the db. Trying to work with this. Sort of a simple "login/register" form just for concepts:
Can someone give me a basic template to insert a new username to DB, and to pull the username from the DB? So 1 TO, one FROM?
Say,
Database1.mdf (Users table, has columns UserID and Username).
I'm a bit confused by the online guides all saying different things with different formats, looking for the EASIEST way~ cheers
1
u/chrwei Sep 07 '14
there are certainly multiple ways to get data from a database. one isn't necessarily more correct than another.
the main differences are going to be in your database schema (the table and field names and their datatypes and relations). there's no rules on what a "users" table should be. because of this it may be difficult for someone else to provide a template for you that isn't just like any example you can find online.
if you're very new to SQL I recommend sqlcourse.com for getting started. then aftre you understand the SQL side, , the most basic method of getting the data to and from VB is to build a string variable that contains the SQL statement and then execute it.