|
You're not going to use any kind of For/Next loop at all in this. You simply keep track of the row you're in in a simple integer variable. Every time you click Submit, or whatever you're calling your button, you put the textbox values in the cells, then increment the variable to point it at the next row. Check the variable to see if it's gone too far and adjust as you see fit. Then, you do nothing... The whole process starts over again on the next button click.
|
|
|
|
|
I have a question:
How can I create a search textbox that would find a certain person in my phonebook. I have created an acces database with a table phonebook. I imported it into my project and then created a form on which I dragged this textboxes which are connected to different fields ( firstname, lastname, adress, number, etc. ) via lets say phonebookBindingSource. I am describing this so in case you write a code, you could write it specificaly for my case. Any comments are very welcome othervwise it's like useless
help tutorials which are made for those who already know all that not for those who want to learn. Anyway I have tried quite a lot including building queries in access and then using that in VB and it doesn't work.
I should write the lastname in a textbox and then clik search button. So I suppose I shuld writte in a Button1_Click Subroutine what?...
But the primary key is on ID not on Lastname or name. There can be different persons with the same lastname so with each click it goes to the next and when at the end of table the procedure should go round again. The easiest way and comments pretty please.
|
|
|
|
|
I wanted to add that the name of the imported database is phonebook.mdb. I found some examples on the internet and they don't work.
as I have read I think I should make a database object and recordset. can I do this with a query like I put some kind of a statement in the criteria box which means whatever is written in the box of this querie field it filters out the records with matched lastnames...
|
|
|
|
|
BOREC wrote: I found some examples on the internet and they don't work.
I'm afraid they almost certainly do. You should take one example and work with it until you can make it work locally, asking specific help questions there or here.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
select top 1 * from tblPhoneBook where firstlame like '%firstName%' and lastname like '%lastname'
is something like the query that would do this, and yes, you do need to write a button click handler for your button to do something.
dragging buttons, and binding sources, is not programming. It sounds to me like you need to buy a good book and work through it, you need a foundation to be able to make the most of online resources.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Somebody got up on the wrong leg I suppose...
I want to implement a simple search engine for a simple phonebook, not creating Windows 3000. I tried some examples and so I got it to work but this is a bit heavier. I didn't find any suitible example I turned here. I didn't find anything promissing so I ...
And I do thing VB is abaut dragging controls to forms and adding functions to it otherwise you would still use assembler language.
|
|
|
|
|
BOREC wrote: And I do thing VB is abaut dragging controls to forms and adding functions to it otherwise you would still use assembler language.
It people like you who give VB a bad name. Christian is correct. Programming, in ANY language, is NOT just dragging controls onto a form and sprinkling it with code.
You MUST understand how and why the controls work and precisely what they are used for. In that understanding you will also learn the limitations or those controls and also learn who to expand on their capabilities.
After reading your original post, you have an interface design problem. Normally, lists like that are shown AS LISTS, not each record individually. It can be done though. But your interface choice makes it more difficult to do and can NOT be done by just dragging and dropping controls. You'll have to write quite a bit of code and completely understand how data binding works and how to set it up manually in your own code, because that's exactly how it needs to be done.
Can I supply a code sample and write you're stuff for you? Nope. There's too much to write in a forum post and you wouldn't learn anything in the process.
Basically, your form has to be able to switch between two datatables. The first one you already have. The second one, you have to make entirely in code, this is the result of your "filter search", and setup the control bindings to point to it - manually.
When you click another button to clear the search results, you reset the control bindings to your original datatable.
|
|
|
|
|
BOREC wrote: I want to implement a simple search engine for a simple phonebook, not creating Windows 3000.
That's why I suggest you read a book. If you wanted to do something complex, I'd have said to forget it.
BOREC wrote: And I do thing VB is abaut dragging controls to forms and adding functions to it otherwise you would still use assembler language.
As Dave said, this is why VB has a bad name. You can create something that does something without ever writing code, but
a - that's not programming and
b - you'll hit the limits of that approach pretty fast.
I wasn't trying to be rude, I was trying to give good advise. I stand by it, if you want to be a programmer, you have to write code. If you find code on the web, you need to do some research to understand what it is you're adding, otherwise you're at the mercy of whatever google throws at you, and you'll never make the bits you paste in talk to each other nicely. Either way, you should always read a book as the first step to learning a new language, then you can have a basis from which to learn via code snippets and forums.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Niether I wanted to be rude. Never said I was a top class programer otherwise I wouldnt be here. Never had any complaints abaut VB or other programs nor wanted to upset you especially if you participated in development in this kind of software. I read for me interested sections in VB for dummies, VB from novice to pro, MS VB step by step and some web pages. I know I have a lack in object oriented programing cause I am now learning for abaut a week and although I don't know all the modules, proceedures, events, ... I shouldn't be able to writte some programs which could be very helpfull. I am not trying to sell them or anything. Don't want to molest you too. Just seeking for little help. Examples are mostly without proper comments. Like a reciepe with ingredients and no how to sentences.
Examples which are given are to easy like read text from textbox1 and write it to another one, some calculators, etc. I haven't had the opportunity to se the code behind move next button in databasebinding navigator or save or add, with some minimum explanation. Thats how you learn programming. By good examples with comments. I was very stunned when practically no good examples of a search engine was not found on the web, because this is one of the most common objects you use in a database. I have seen some good examples abaut graphics and creating a simple paintbrush or a simple web browser, so. Don't want to bore you but I admire your work but you should be a little more tolerant and plastic or open minded. Sorry for spending your time, but I thought you should abaut my situation, cause...
|
|
|
|
|
This is the code I found...
Public Class Form2
Dim dbMyDB As Database
Dim rsMyRS As RecordSet
' this part is supposed to create a recordset of phonebook table in phonebook.mdb
Private Sub Form_Load()
Set dbMyDB = OpenDatabase("Phonebook.mdb")
Set rsMyRS = dbMyDB.OpenRecordSet("phonebook", dbOpenDynaset)
If Not rsMyRS.EOF Then rsMyRS.MoveFirst
Do While Not rsMyRS.EOF
lstRecords.AddItem rsMyRS!Name
lstRecords.ItemData(lstRecords.NewIndex) = rsMyRS!ID
rsMyRS.MoveNext
Loop
End Sub
Private Sub Button1_Click()
rsMyRS.FindFirst "ID=" & Str(lstRecords.ItemData(lstRecords.ListIndex))
txtPhone.Text = rsMyRS!Phone
End Sub
End Class
|
|
|
|
|
Again, 'finding' code is not the same as understanding how to use it.
This looks like a disaster to me. I would throw this in the bin and use the database to do your searching, that's what it's for.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
This is what I found on the web. I want it to make it work. It describes a bit of it's funcionality but very scarce. Never give up I say. I hopped you could correct it a bit and added some comments. Whell in the datanavigationbar if I am not mistaken there is a textbox that automatically displays the index position of the currenty displayed record. If I write lets say 10 in it and press enter then it automaticaly jumps to record number ten. How can I see the code behind it, I could certainly use the code and learn from it. If I double click on it then I get in the form class another subroutine with click event. the same I would like to se for move next button and save and so.
Don't get upset please cause I don't want anyone to get a stroke or diarea or something like that...
Greetings.
|
|
|
|
|
BOREC wrote: Don't get upset please cause I don't want anyone to get a stroke or diarea or something like that...
LOL - I'm not even remotely upset.
BOREC wrote: I hopped you could correct it a bit and added some comments. Whell
Well, I'm saying that you need instead to do things the right way, write some SQL that requests the data you want from the DB. I gave you the SQL in my first reply, or at least an approximation of what it should be.
The way I would write a method that views one record at a time would depend on the data set. If it was not huge, I'd read it all from the DB and just step over it with my buttons. I'd still not look for records in memory, I'd still write SQL and let the DB do that for me. I'd use my existing functionality then to step over the matches, as my collection would only contain records that match.
http://www.developerfusion.co.uk/forums/p/28135/104686/#104686[^] has a reply showing how to do a dynamic search in Access with VB.NET. It was the first hit when I googled 'vb.net search access database', it looks like a good place to start.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I write name in textbox1 and click button1 for search:
code:
Private sub Button1_Click(...)
Dim VSearch as String
VSearch = TextBox1.Text
WORK.Recordset.FindFirst(VSearch)
End Sub
although original is
Private sub Button1_Click(...)
Dim VSearch as String
VSearch = "NAME="+TextBox1.Text
WORK.Recordset.FindFirst(VSearch)
End Sub
I WORK table in PhonebookDataSet and in the table fields: name, lastname, officephone, etc.
Please help
|
|
|
|
|
OK - so the problem is solved, or you found another code snippet that doesn't work and you're asking how to make it work ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I'm getting an unusual error message may be I'm wrong here is the error can anyone please tell me how to resolve it:
The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF
And here is the code that raised this error:
Dim wr As HttpWebRequest
Dim wrs As HttpWebResponse
wr = HttpWebRequest.Create("http://www.google.com/")
wr.Method = "HEAD"
wrs = wr.GetResponse()
MsgBox(wrs.Headers.ToString())
AliAmjad(MCP)
First make it Run THEN make it Run Fast!
|
|
|
|
|
According to the error message, your code didn't generate the error, Google's web server did. HttpWebRequest is correct is saying so because it's following the parsing rules for HTTP 1.1 headers closer to the RFC specification than Google web server did putting the headers together. It's not Google's fault really, but the people who wrote the web server. There's an old recommendation in the RTF for HTTP 1.0 that said something like:
"the line terminator for message-header fields is the sequence CRLF. However, we recommend that applications, when parsing such headers, recognize a single LF as a line terminator and ignore the leading CR."
The headers comming back from the server ARE, according to which section of the RFC for HTTP you're reading, malformed.
You can turn on an option in your applications app.config file to force HttpWebRequest to relax it's parsing rules and suddenly start working with a large collection of web servers that were never "fixed" because "they worked before!"
<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>
|
|
|
|
|
I've done some research before posting this question on Code Project and found the same solution in Msdn forum and did the same thing but it didn't display the headers received from the server but now it did I think there was something wrong with my network connection. As far as solution goes don't you think that Microsoft should make this class more fault tolerant so that it can handle such situations.
AliAmjad(MCP)
First make it Run THEN make it Run Fast!
|
|
|
|
|
AliAmjad wrote: As far as solution goes don't you think that Microsoft should make this class more fault tolerant so that it can handle such situations.
They did!! As I've already said, you have to turn this option on in order to use the non-RFC compliant parser. In this particular case, the guy who the HttpWebRequest class wasn't as lazy as the guy who wrote the web server that Google, and tons of other sites, are using.
|
|
|
|
|
Hi guys !!!
can you help me?
How can i send email with vb 2005?
NOt using Outlook or another.
show me an example please
i'm from mexico.....thanks code project !!!
|
|
|
|
|
|
I created a program using visual basic. For some functions the program accesses a dll which was created using visual c++. When the program is run on a computer that does not have visual studio installed, functions which make calls to the dll generate an error:
Unable to load DLL 'filename.dll': This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1).
Reinstalling the application does not help, and when the program is run on a computer that does have visual studio installed, calls to the dll work as expected without generating any type of error.
Is there some component that is installed with Visual Studio that I need to attach to my program installation? Is there some way I can create or access the dll such that it does not need this component?
|
|
|
|
|
What version of Visual Studio was used to create this .DLL?? You're probably missing installing the updated runtimes that the .DLL uses to get this to work. Look in the C:\Program Files\Microsoft Visual Studio version\VC\redist\x86 folder for all the available runtimes. Pick the one that describes what you used to create the .DLL. At a minimum, you'll need to copy the .CRT .dll's to the target machine's Windows\System32 folder.
|
|
|
|
|
Thanks for the suggestion. The development version I am using is Visual Studio 2005 (Also comes up as Visual Studio 8). I tried two different things to try and solve the problem. When I created the install for the program I attached the prerequisite "Visual C++ Runtime Libraries (x86)". So the setup installs the runtime libraries first. This did not solve the problem. Second thing I did was what I think you told me to do. I copied the files from the C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT\ folder to the target machine's Windows\System32 folder. This did not solve the problem either. There are other folders in the x86 folder: Microsoft.VC80.ATL, Microsoft.VC80.MFC, Microsoft.VC80.MFCLOC, Microsoft.VC80.OPENMP. Should I try copying the dlls from any of these folders as well? Thanks for the help.
|
|
|
|
|
Member 4084928 wrote: There are other folders in the x86 folder: Microsoft.VC80.ATL, Microsoft.VC80.MFC, Microsoft.VC80.MFCLOC, Microsoft.VC80.OPENMP. Should I try copying the dlls from any of these folders as well?
Only if your DLL is using MFC, ATL, or the OpenMP libraries, which I seriously doubt.
In this case, I have no idea. The HRESULT you got usually means that the code you're attempting to run depends on code found in other DLL's, but those dependant DLL's cannot be found, or cannot be loaded for some reason. The missing runtimes is usually the cause of this problem. But, it appears that your DLL is dependant on other DLL's, but you haven't supplied any information on what other libraries your DLL uses.
Other possibilities include the users permissions to the DLL's being loaded, code access security problems, incorrect .config file for the app loading the DLL's, the version of the .NET Framework you developed against is not installed on the target machine, ..., ..., ...
This question would be better asked in the Visual C++ forums.
|
|
|
|