how to get null field value from access in vb6

in my 2 record field the value is empty but i'm not able to get that empty field in vb6

...
....
set rs = new adodb.recordset
rs.open ("select * from table1 where id = '2'")
text1.text = rs!name

please help me out

Recommended Answers

All 5 Replies

If I read this correctly, you have opened the recordset where the id = 2. According to you, the name field is empty??? thats why nothing shows in text1.text. What seems to be the problem then?

To check if it IS empty, you can do teh following...

If rs!name = vbnullstring Then
    msgbox "No Value Here..."
        Else
    text1.text = rs!name
End If

if i want to enter the text in the text1.text where the record field is null & save the it. what kind of code do i need to use there

please help me out

do the following...

...
....
set rs = new adodb.recordset
rs.open ("SELECT * FROM table1")

rs.AddNew
rs!name = text1.text
rs.update

If you want to save it to that specific record, do this...

...
    ....
    set rs = new adodb.recordset
    rs.open ("SELECT * FROM table1 WHERE id='2'")

    rs!name = text1.text
    rs.update

Is this code is correct to enter the empty record field

dim cn as new adodb.connection 
set cn = new adodb.connection
cn.execute "UPDATE Table1 SET T_city = '" & text1.text & "' where ID = '2'"
cn.close: set cn = nothing 
commented: its a pleasure +12

Almost :)

dim cn as adodb.connection ''removed new... 
set cn = new adodb.connection
cn.execute "UPDATE Table1 SET T_city = '" & text1.text & "' where ID = '2'"
cn.close 

Should work just fine.

commented: thanks +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.