| | |
ADODC syntax
![]() |
•
•
Join Date: Sep 2007
Posts: 70
Reputation:
Solved Threads: 0
Hi everbody,
I have used one ADODC control in my VB6 prog with SQL 2000 as backend. I have completed the connection of ADODC using UDL file and it's working fine
But when i write the following syntax to retrieve data its not working: The code is as under:
Private sub cmdview_click()
adodc1.recordsource = "Select name from emp where name=Arun"
text1.text =adodc1.recordset
endsubI tried this code also:
adodc1.recordset ="Select name from emp where name= ' " & text2.text & "' "
But this also did not work.
whereas cmdadd is working fine where the code is written as under :
adodc1.recordset. Addnew
Adodc1.recordset!name =text3.text
Pl help me early.
(Kehar Singh)
T
I have used one ADODC control in my VB6 prog with SQL 2000 as backend. I have completed the connection of ADODC using UDL file and it's working fine
But when i write the following syntax to retrieve data its not working: The code is as under:
Private sub cmdview_click()
adodc1.recordsource = "Select name from emp where name=Arun"
text1.text =adodc1.recordset
endsubI tried this code also:
adodc1.recordset ="Select name from emp where name= ' " & text2.text & "' "
But this also did not work.
whereas cmdadd is working fine where the code is written as under :
adodc1.recordset. Addnew
Adodc1.recordset!name =text3.text
Pl help me early.
(Kehar Singh)
T
Hi,
Immediately after setting recordsource, you have to refresh..
try this :
Also check, ConnectionString is set before running the above code..
Regards
Veena
Immediately after setting recordsource, you have to refresh..
try this :
vb Syntax (Toggle Plain Text)
adodc1.recordsource = "Select name from emp where name='" & Text2.Text & "'" Adodc1.Refresh text1.text =adodc1.recordset.Fields(0)
Also check, ConnectionString is set before running the above code..
Regards
Veena
•
•
Join Date: Sep 2007
Posts: 70
Reputation:
Solved Threads: 0
•
•
•
•
Hi,
Immediately after setting recordsource, you have to refresh..
try this :
vb Syntax (Toggle Plain Text)
adodc1.recordsource = "Select name from emp where name='" & Text2.Text & "'" Adodc1.Refresh text1.text =adodc1.recordset.Fields(0)
Also check, ConnectionString is set before running the above code..
Regards
Veena
Although I have written the connection string in Form load view.
and even the ADODC has been connected to the database using DSN in its property window.
Earlier when I did not use ADODC control in form that time I used to write the following code in General declaration view of Code
Dim cn as new ADODB.Connection
Dim rs as new ADODB.recordset
Should I write the above code even after using ADODC control in General declaration ?
(kehar singh)
•
•
Join Date: Sep 2007
Posts: 70
Reputation:
Solved Threads: 0
•
•
•
•
that is your "first field" which is "name" no need to type the name.
have you try this one? Adodc1.Recordset!name = text1.text
Dim cn As New ADODB.Connection ' in General declaration
Private Sub cmdaddnew_Click() ' This is working fine
Adodc1.Recordset.AddNew
Adodc1.Recordset!ono = Text6.Text
Adodc1.Recordset!ord = Text7.Text
Adodc1.Recordset!pop = Text8.Text
End Sub
Private Sub cmddelete_Click() ' Not working
Adodc1.Recorsource = "Select * from aot where ono='" & Text9.Text & "'"
If Adodc1.Recordset.EOF Then
MsgBox "Record not found"
Exit Sub
Else
Adodc1.Recordset.Delete
End If
End Sub
Private Sub cmdview_Click() ' Not working
Adodc1.RecordSource = "Select ord from aot for pop='" & Text9.Text & "'"
Text3.Text = Adodc1.Recordset.fields(1)
End Sub
Private Sub Form_Load() 'its Ok
cn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ao"
cn.Open
End Sub
command under cmdview and cmd delete are not working
Pl help me
Kehar singh
•
•
Join Date: Jan 2007
Posts: 164
Reputation:
Solved Threads: 10
Dim YourTextbox as string
Use YourTextbox in query
instead of the Object;
another is use trim() may be you have some spaces.
after query use refresh
Adodc1.Refresh
Wrong spelling on Recordsource: Adodc1.Recorsource = "Select * from aot where ono='" & Text9.Text & "'"
In delete.
Adodc1.Recordset.Delete adAffectCurrent
Use YourTextbox in query
instead of the Object;
another is use trim() may be you have some spaces.
after query use refresh
Adodc1.Refresh
Wrong spelling on Recordsource: Adodc1.Recorsource = "Select * from aot where ono='" & Text9.Text & "'"
In delete.
Adodc1.Recordset.Delete adAffectCurrent
Last edited by rm_daniweb; Apr 14th, 2009 at 1:05 am.
![]() |
Similar Threads
- access to Datagrid...show in DBGrid (Visual Basic 4 / 5 / 6)
- Executing Query with criteria at run time (Visual Basic 4 / 5 / 6)
- ADO Data Control (ADODC) Problems with .recordset.find (Visual Basic 4 / 5 / 6)
- Creating Oracle Users (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Visual Basic 5.0 Help
- Next Thread: SEGY binary format
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





