| | |
Editing a record!
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2008
Posts: 161
Reputation:
Solved Threads: 1
help theres nothing happen everytime i search a record
heres my code
nothing happen to my text fields
heres my code
Dim a
a = InputBox("Input Product Code :", "Find", "")
If a = "" Then
Exit Sub
End If
Set rs = New ADODB.Recordset
rs.Open "Select * from Product where pcode='" & a & "'", cn, adOpenStatic, adLockPessimistic
Set MSHFlexGrid1.DataSource = rs
If rs.RecordCount > 0 Then
rs.Fields("pcode") = Text1.Text
rs.Fields("brandname") = Text2.Text
rs.Fields("genericname") = Text3.Text
rs.Fields("price") = Text4.Text
Command1.Enabled = False
Command2.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
End Ifnothing happen to my text fields
•
•
Join Date: Mar 2008
Posts: 3
Reputation:
Solved Threads: 1
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim a , strsql as string 'pls check your inputbox forget using it 'idont have any vb6 installed in my pc , now using csharp2005 a = InputBox("Input Product Code :", "Find", "") If a = "" Then Exit Sub 'think this would help strsql = " select * from Product " strsql = strsql & " where " strsql = strsql & " pcode='" & trim(a) & "'" Set rs = New ADODB.Recordset rs.CursorLocation = AdUseClient rs.open strsql, cn, AdOpenForwardonly, AdLockReadonly 'exit if no record if rs.Recordcount = 0 then exit sub if rs.Recordcount > 0 Then 'display record in textbox 'hope it helps Text1.text = rs.Fields("pcode") Text2.Text= rs.Fields("brandname") etc.... Set MSHFlexGrid1.DataSource = rs end if Command1.Enabled = False Command2.Enabled = False Command4.Enabled = False Command5.Enabled = False
Last edited by Ancient Dragon; Jan 5th, 2009 at 3:17 pm. Reason: add code tags
•
•
Join Date: Jul 2008
Posts: 161
Reputation:
Solved Threads: 1
thanks its work but i have problem in saving a data
Set rs = New ADODB.Recordset
rs.Open "Select * from Product", cn, adOpenKeyset, adLockPessimistic
If Not rs.EOF Then
rs.Fields("pcode").Value = Text1.Text
rs.Fields("brandname").Value = Text2.Text
rs.Fields("genericname").Value = Text3.Text
rs.Fields("price").Value = Text4.Text
rs.Update
End If
i hope you can help me
Set rs = New ADODB.Recordset
rs.Open "Select * from Product", cn, adOpenKeyset, adLockPessimistic
If Not rs.EOF Then
rs.Fields("pcode").Value = Text1.Text
rs.Fields("brandname").Value = Text2.Text
rs.Fields("genericname").Value = Text3.Text
rs.Fields("price").Value = Text4.Text
rs.Update
End If
i hope you can help me
I'm a little confused.... you are trying to save data? If so, you wouldn't open a connection to the database with a Select... Select is used to retrieve rows and columns from the database table.... I think you want something like with like
UPDATE table SET field = 'whatever' WHERE column = 'something' Last edited by Comatose; Jan 2nd, 2009 at 11:16 am.
![]() |
Similar Threads
- Populating form with existing MySQL data (PHP)
- edit data problem (Visual Basic 4 / 5 / 6)
- Audio signal capturing & editing (VB.NET)
- Can Access update the currnet record or multiple records using a macro? (MS Access and FileMaker Pro)
- Receiving closed filehandle warning (Perl)
- Large Database record editing recommendation (VB.NET)
- example of editing in DataGrid and Default Paging (ASP.NET)
- Help editing table (Java)
- Updating a record in an MS Access database file using DataSets (VB.NET)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: changing the backcolor
- Next Thread: Audio volume control on vb6 form
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column 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 retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






