ok i kno wthe other thread i made was stupid but this one actually has use, first off how can i code a button to add a row to a database and make the row a yes/no so it will show as a radio button on the form and stay there, second i remember reading somewhere you can make a magnifing glass type thing but can u make a program that will magnify part of the screen u tell it and that part becomes fullscreen so you can click on it?

To add a row in the database you need to the following things:

imports system.data.oledb
Private mycomm As New OleDb.OleDbCommand
Private myconn As New OleDb.OleDbConnection
'The following code goes under the button procedure.
Dim strquery as string
myconn.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=(location of database);User Id=admin;Password=;"
strquery = "INSERT INTO (put table name here) VALUES (put values here)"
mycomm.connection = myconn
mycomm.commandtext = strquery
mycomm.executenonquery
strquery="SELECT (yes/no column) FROM (table name)"
mycomm.commandtext = strquery
if mycomm.executescalar = yes then
[INDENT]radiobutton1.checked = true[/INDENT]
else
[INDENT]radiobutton1.checked=false[/INDENT]
end if

I am sorry, but I do not know how you would achieve the magnifying glass effect, but I would try to use flash to do it.

Hope this helps

im sure it would help if i knew how to incorperate it into my program, but mine is a little bit, how do i put it, i dont even know where to start figuring out how to use your code in my code. my program is just like to i guess basic or easy for your code, for example

myconn.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=(location of database);User Id=admin;Password=;"
strquery = "INSERT INTO (put table name here) VALUES (put values here)"

to make my database i found it easier to use the database wizard so it added everything for me, so i dont know the full location, i could prob find it, but then i dont know the values, plus i dont understand the rest of the coding

im sure it would help if i knew how to incorperate it into my program, but mine is a little bit, how do i put it, i dont even know where to start figuring out how to use your code in my code. my program is just like to i guess basic or easy for your code, for example

to make my database i found it easier to use the database wizard so it added everything for me, so i dont know the full location, i could prob find it, but then i dont know the values, plus i dont understand the rest of the coding

Sorry, I sometimes get a little ahead of myself. Let me explain the code. The 'imports' statement at the top just retrieves the namespace needed for the code to work. The two following variable declarations do not have to declared privately, but they are the command, which tells the program what to do with the database, and the connection, which connects to the database. 'Strquery' is a string which will be used for SQL statements. SQL statements are used to interact with the database and can insert data, retrieve data, and can also do many other things. To get started with SQL you should look at this tutorial: http://w3schools.com/sql/default.asp. The connection is then attributed a connection string (where the program will look for the database). All you need to do is specify the location. Now the following statement is a SQL statement. It has to be fully enclosed in quotes. This SQL statement will insert a new row in your database, but it first needs to know the table name and the value(s). For example:
strquery = "INSERT INTO Persons Values ('" & textbox1.text & "','" & textbox2.text & "')
Whenever you insert strings into a database using SQL statements, you must enclose it in single quotes, so in VB it is a bit different since the single quotes are for commenting. In the next line you are assining the command the connection in which it will insert the data. IMPORTANT! Sorry, but I forgot to do this in my first post, but after assiging the command to the connection, you have to open it like this: myconn.open The next statement gives the SQL statement to use, and executes it after that. I not sure if I understand what you would like to do after, but from what I understand, you can just have an 'If...then' statement that checks the radio button according to the value entered. If you have any more questions, don't hesitate to ask!

ok, somethings screwd up, i looked at my database and realized i had typed it up on the save table so to add a new class to the program i will have to add a new column, i think i will try to use the code u gave me but... do i need to

myconn.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=(location of database);User Id=admin;Password=;"

if i have an oledbdataadapter? also could i use the creat index function to make it so i can have a search box for the program?

p.s. slry it took me so long to reply, i read through the whole tutorial before i responed, also i dont know when ill be able to work on adding it to the code because ive been loaded with work that i need to do:(

ok, somethings screwd up, i looked at my database and realized i had typed it up on the save table so to add a new class to the program i will have to add a new column, i think i will try to use the code u gave me but... do i need to

myconn.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=(location of database);User Id=admin;Password=;"

if i have an oledbdataadapter? also could i use the creat index function to make it so i can have a search box for the program?

p.s. slry it took me so long to reply, i read through the whole tutorial before i responed, also i dont know when ill be able to work on adding it to the code because ive been loaded with work that i need to do:(

No problem, but I am pretty sure that it will work with the oledbdataadpater and you can also use the create index function, and any SQL function for that matter.

sorry its been so long since ive posted, but i have ben really busy and still havnt worked on that program but before i did i was going to ask you, if i use the oledbdataadapter would i have to do this

myconn.connectionstring = "oledbdataadapter"

or what? also with the contex index or whatever do i have to go into the oledbdataadapter and under quiries where you choose what column you want of what table would i have to add CONTEX INDEX = Employee_ID or would i CONTEX INDEX = Employee_ID = parameter1 or niether? what would i do to do the searching?

This article has been dead for over six months. Start a new discussion instead.