Hi all this is the first time here.
I'm trying get my program to search a database. I've been using a datagridview to display data from my database.
i'm also trying to get it to let me add data to an empty space. I'm desperate for help.
Printable View
Hi all this is the first time here.
I'm trying get my program to search a database. I've been using a datagridview to display data from my database.
i'm also trying to get it to let me add data to an empty space. I'm desperate for help.
Hi Welcome to VBF!
is your search working fine...where do you get stuck...and what is the error if any...do you have any codings done so far...
I've just started with the basic form up and just need it to search a database for something and then display it on a different screen. I've got the info to display on the datagrid but that's about it.
kinda new to vb just learning rite now and my course teachers suck
Hello,
If you're using a datagrid then you must have created an ADO Data Control (6.0) embedded in the form! Am I right.
If so to search the data on the control
VB Code:
Private Sub cmdSearch_Click() Dim strName As String Dim Book Book = adodc1.Recordset.Bookmark strName = InputBox("Please enter a Title") adodc1.Recordset.MoveFirst strName = "'" & strName & "'" adodc1.Recordset.Find "Title = " & strName If adodc1.Recordset.EOF Then MsgBox "Title does not exist" adodc1.Recordset.Bookmark = Book End If End Sub
This is a very simple search that calls an inputbox and then locates the first record that matches strName.
To add a new record
VB Code:
adodc1.Recordset.AddNew
The difficulty you will have using the Data Control is that there is only a single way to refresh the data and I believe that to be out of the scope of your course.
Please also be aware that I am not going to do your coursework for you. The code above searches a data control relating to the data source given to the control at design time. Your data control will require a different a search under a different field within your control.
Steve
thanks i'll work it out from here but might come and ask more questions later if i get stuck.
btw i'm not expecting anyone to do the code for me I'd rather learn wot i need but our teachers don't know how to do the database part so our class is having to get outside help but thanks. just to let u know i'd rather work for it and not be spoon feed information
Hello again,
apologies for not getting back to you.
It is always a positive step to want to figure the program out for yourself as most people learn programming that way.
Also when you are stuck just post your code, using the vbcode tagging system, and you will mugged by the many here who enjoy helping broken code get fixed.
Regards
Steve
PS you will find a great amount of code available in the VB Classic FAQ .
kool thanks. I've had a look and tryed it but it won't recognise the "adodc1" it keeps telling me it's not declared so i donno if it's just visual studios 2005 being dumb or if i've done something wrong.
For working with databases, VB 2005 (which is VB.Net) is very different to Classic VB (VB6 etc), which is what sparbag assumed you were using.
I'm afraid that like many others here, I don't use VB.Net myself, so unfortunately I can't help. :(
rite then thanks for trying.
for all you out there help please.
Hello again,
.NET at this level is certainly grabbing the dinosoar by the tail [sic].
O'Reilly
Generously donated code
HTH
Steve
thanks