On Aug 06, 2006, at 2:38 PM, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote:

Hi All.

SQL question from the sql greenie here.

I'm trying to add a row of data to a table I've created. The following code will do it if i make everything static. However, I want to take information from two editfields and a dropdown box.

I don't get any error, however, I don't get any table entry.

SQL is another programming language you're using inside RB
It has it's own rules

db.SQLExecute("insert into users (username, password, securitygrp) select "_
    +"(edituser.text, editpassword.text, popupsecuritygrp.text)")

Take this and put it into a variable for now JUSt so you can see the result. Put a break point ON the db.sqlexecute so you can see what SQL you are about to send to the database to execute.

        dim sql as string

sql = "insert into users (username, password, securitygrp) select (edituser.text, editpassword.text, popupsecuritygrp.text)"

        dbsqlexecute(sql)

IF you typed this in to a SQL tool and ran it it would give you an error

What you want is the VALUE of edituser.text, editpassword.text & popupsecuritygrp.text in the VALUES clause of the SQL

Normally an insert looks like

        insert into TABLE (columnnames...) values ( columnvalues.... )

There IS a variant that uses a select but that assumes you have data IN a table already not variables in your program

So, to get the VALUE of the variables try

        dim sql as string

sql = "insert into users (username, password, securitygrp) VALUES ( '" + edituser.text + "', '" + editpassword.text + "', '" + popupsecuritygrp.text + "')"

        dbsqlexecute(sql)

This concatenates the VALUE held in each of your fields onto a string that is then the SQL to run

Now, there MAY be some issues (like if a field holds a string that contains a quote) but this should get you started


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to