Click to See Complete Forum and Search --> : ??? help. totally confused ????


fated_guys
October 9th, 2004, 08:00 PM
I need help to solve some things... I'm using MS Access, VB, ADO and ADOX

1.] how do make my tables accept NULL values? I already set the column's properties NULLABLE to true. but when i make queries like the one below, I'd get an error. hmmm... i messed up somewhere didn't i?

Cmd = "INSERT INTO Student VALUES('" & StudentID & "', '" & Last_Name & "', '" & First_Name & "', '" & Middle_Initial & "', '" & Course & "', '" & NULL & "', '" & NULL & "', '" & Final_Grade & "', '" & Final_Letter_Grade & "')"



2.] After making a select query how do I assign data from tables to a variable? Is it possible? You see, I have to make a select query then perform some mathematical operation before I assigned the product to another column of same table. In addition, i have to compare user's input against the data in the table and the only way I know how is by assigning the data to a variable before making comparison.


please help me because i'm already 35% away from project completion.

spuppett
October 14th, 2004, 11:52 AM
in response to #2:

What works for me is:

dim var as dataType

var = dataObj.recordset.fields("fieldname").value

TheCPUWizard
October 14th, 2004, 12:24 PM
In response to #1, it is almost always a bad idea to not specify the columns explicitly for an SQL operation.. Also, this type of structure is very prown to sql inject ion attacks.

If you re-write your code to properly specify the columand and use parameters for the data, then all your problems will be solved.

[OK, not ALL your problems but at least this one ;) ]

Madhi
November 5th, 2004, 09:08 AM
Hi fated_guys, If you want to insert null value just dont insert any value for that columns. otherwise try the following
Cmd = "INSERT INTO Student VALUES('" & StudentID & "', '" & Last_Name & "', '" & First_Name & "', '" & Middle_Initial & "', '" & Course & "', NULL, NULL, '" & Final_Grade & "', '" & Final_Letter_Grade & "')"

Madhivanan

erickwidya
November 5th, 2004, 09:04 PM
try inserting NULL value without single quote or not passing it as string or vbNull

"INSERT INTO Table1 VALUES(NULL, NULL, NULL)"
regards