|
I created a dataset through access database. I just need the search, or find engine to locate the files faster, if the files are too long. I would do the same thing as you suggested. Mine is an address book, and I also have a password dialog. How would I also can make the password dialog, if i want to change my password code?
My addressbook consist of First Name, Last Name, Address, City, State, Zip Code, Email. I would like to have a search button with code. Then I use a select statement for every field, then when the dataset populates, I can use the search and input box to enter the name of the person I am looking for?
Or do I have to enter in a case select every persons name within a dataset?
bravo659
|
|
|
|
|
Hi Brit,
search through your dataset/datatable using the datatables "Select" method. It takes a string parameter in the form of a T-Sql like select statement. ex:
'create your dataset and datatable etc...
Dim ds as New Dataset("myDataset")
Dim dt as New DataTable("myDataTable")
dt.Columns.Add(New Datacolumn("columnOne", sqldbtype.varchar)
dt.Columns.Add(New DataColumn("columnTwo", sqldbtype.varchar)
'some code to populate the table here...
'search column one for 'Foo'...
dim drResultsColOne() as Datarow = ds.Tables("myDataTable").Select("columnOne = 'Foo'")
'search column two for 'Foo'...
dim drResultsColTwo() as Datarow = ds.Tables("myDataTable").Select("columnTwo = 'Foo'")
'or search both columns for 'Foo'...
dim drResultsBoth() as Datarow = ds.Tables("myDataTable").Select("columnTwo = 'Foo' OR columnTwo='Foo'")
the result is a datarow array that contains the datarows that match your search criteria.
forgive any spelling errors, this was typed off the top of my head.
-jim
|
|
|
|
|
If you search for 'Foo', will it find Food? If so, how to I get the information from the array?
Thanks,
Beginner in ASP.Net and VB.Net
|
|
|
|
|
no, if you were to search for 'Foo' it would not include any rows with 'Food' in column1 or column2, as Foo and Food are not equal.
However the select statement does support the use of wildcards, so a search for 'Foo%' would include any rows with 'Food', 'Foos' or 'Fool' as well as, but not include rows with 'Ofoo' or 'Afoo' in columns 1 or 2. You can also use '%Foo%' to search for 'Afool', but note that if your datasource is large enough, you could see a performance hit when using wildcards on both sides of your search value.
as for getting the data from the array, you would work with the datarwow array as you would with any other array. from my previous example:
drResultsBoth(0) would give you the datarow at position 0 in the drResultsBoth array.
typically you would enumerate over the array to perform some sort of change on a field in the datarow. ex:
if (drResultsBoth.Length > 0) Then
For Each currentRow as Datarow in drResults
if (cstr(currentRow("ColumnOne")).trim = "Foo" Then
currentRow("ColumnTwo") = "Bar"
End If
Next
Else
messagebox.show("No results were found for your search criteria!")
End IF
hope this helps
-jim
|
|
|
|
|
Is it possible to search through the dataset using a select statement? If so how? That is really what I need. So if the user does search for 'foo' then I want to capture the first match. If there is a value of food and foot in the database, then which ever one is first in the database I will display. I really dont need an array. I just want to search for the value they enter and find the first closest match and display it.
The only thing with using a select statement. I don't think I will be able to find out which row it found the closest match on. Will it?
Thanks,
Beginner in ASP.Net and VB.Net
|
|
|
|
|
>Is it possible to search through the dataset using a select statement?
well, yeah. just keep in mind that the data is stored in the tables within your dataset. so if you want to search accross different tables you would have to run the select statement on each individual table separately. but it seems to me that if your database/dataset design is done correctly you should only have to worry about searching a single table; ideally, only a single field.
in regards to displaying the first match... i would still recommend using the select method. i haven't seen any of your code or db design, so i'm not sure exactly what that looks like, but providing you have a primary key defined and you are carrying that over to your dataset when you load the data, (this should happen automatically if you are using ms sql) the select method of the datatable should use the primary key when searching your datatable and place the items into the array based on the primary key values.
so when you do your select, even though you get back an array you can just take the first item iun the array, index 0, and display the value from the appropriate field.
usually when implementing a search, you want to display more than just a single field value, for instance in the case of a product search, you could take all attributes of the row at array index 0 and place them into textboxes for display/manipulation or insert them into html for display on a webpage.
-jim
|
|
|
|
|
Thanks for the help.;)
Beginner in ASP.Net and VB.Net
|
|
|
|
|
Does anyone out there know of any good articles dealing with remoting? I'm looking to create a client-server application (first one) and would like to implement the use of remoting to transfer business objects back and forth from the server to the client.
Thanks!
|
|
|
|
|
Hi Chris,
You can find enough resources at:
ThinkTecture
I Hope this helps.
|
|
|
|
|
how do i flush sound buffer . i need it because while playing in between if press stop button , it is retaining contents in buffer and again if i press play button it is getting overlapped with previous content of the buffer and there is glitch (problem)while playing at the beginning. i am using "waveoutopen" function
|
|
|
|
|
The problem is you apparently are not stopping the waveOut and Closing the device before you start playing another soung, you're actually appending the new song data to the one still playing.
To flush the buffer, use waveOutReset() and supply it the handle you got back in the first parameter passed to waveOutOpen , then use that same handle with waveOutClose to close and release the device.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
This is probably really simple.
Say I've got a window frmMain. How do I get a handle for that window??
Cheers
|
|
|
|
|
|
Even easier...
Dim myWindowHandle As IntPrt = frmMain.Handle
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi guys can you help me with this one...
I have a loop that calls on an asynchronous method call with callback. obviously, separate background worker threads from the thread pool will be assigned for each method call to manage the execution in parallel path. but i do worry on a number of things:
1. since the asynchronous method call is non-blocking then members of my method is not thread-safe (yaiks!)
2. if i lock the method using MethodImplAttribute or locking variants (synclock, monitor, mutex, etc...) then my asynchronous calls become useless (threads on-queue), i myt as well go back to synchronous calls.
Questions:
1. Are asynchronous calls not thread-safe and non-blocking as i guess?
2. how can i execute thread-safe multiple asynchrounous method calls? what i mean is that each call to the single method by each separate threads should have its own instances/values. different threads should not interfere by altering the values set by other threads running in-parallel. in other words its like giving each thread a segment in the memory where to put its own private transaction with the method being called (private session).
3. are methods of remotable objects (methods of proxies in remoting) activated on the server on Singleton mode thread-safe? how does the remotable object handles simultaneous request from multiple asynchronous calls?
i bet most of you have encountered the same dilemma.
tnx a lot!
|
|
|
|
|
Hello
I am visual Basic 6 guy doing a project in VB.net now. Everything look different from visual basic 6 to .net.
I need help in these things
1. I need to connect an odbc sql connection and how to set a public connection in module
2. what are the references i should have to add and how to add ( similar to how we add in vb 6)
3. Say i have a table called userTB and fields Usercode and userid and password.
i need your help how to get these from the database and check and verify the username and password in a form called Login.vb
If somebody can help me in this with coding and some descriptions then i can use that as a base and develop the applicaiton.
Thanks and regards
vimal
Help in need is the help indeed
|
|
|
|
|
It's not too late to redeem yourself. If you have the full VS.NET, just click on the C# project tab, and you can be saved...
percyvimal wrote:
I need to connect an odbc sql connection and how to set a public connection in module
There are two groups of objects, if you're using SQL Server, then you want to open a System.Data.SqlClient.SqlConnection.
percyvimal wrote:
what are the references i should have to add and how to add ( similar to how we add in vb 6)
System.Data. Anything else you need lives under there, and intellisense should reveal all.
percyvimal wrote:
Say i have a table called userTB and fields Usercode and userid and password.
i need your help how to get these from the database and check and verify the username and password in a form called Login.vb
Use a SqlCommand object ( same namespace as the connection ) to call the stored procedure that gives you this information. You're using a stored procedure, right ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hello Mr Christian,
Thanks for your reply.I am very very basic to vb.net and so i need more precise and elobarate descriptions with codings if possible.
When i do this in vb6 this is how i do
create a public connection in
Public Db As Connection
Sub Main()
Set Db = New Connection
Db.CursorLocation = adUseClient
Db.Open "Provider=SQLOLEDB.1;Password=" & Password & ";Persist Security Info=True;User ID=" & userName & ";Initial Catalog= " & DataBaseName & " ;Data Source=" & ServerName & ""
Frmlogin.Show 1
End Sub
this is used in module. SO when i run the program it go to main function automatically.
So how i do this in vb.net, same thing but how to do in vb.net
Please explain to me in detail with codings and explain to me what referece to add and from where i have to add the reference.
I am not using Stored procedure
this is how i open a recordset using vb6
Dim Logrs as new recordset
set Logrs= New recordset
LogRs.Open "select [LoginID], [UserName],[password] from loginmaster where [UserName]='" & Trim(TxtUserName.Text) & "'", Db, adOpenDynamic, adLockOptimistic
If LogRs.RecordCount <> 0 Then
If LogRs.Fields("password") = Encrypt(Trim(txtnewPwod.Text)) Then
LoginId = Val(LogRs.Fields("LoginID"))
Unload Me
Administrator = False
FrmDonor.Show 1
Else
MsgBox "Wrong password", vbCritical, App.ProductName
Exit Function
End If
Else
MsgBox "Username not exists", vbCritical, App.ProductName
End If
So how i can do this using vb.net,
Thanks and regards
vimal
Help in need is the help indeed
|
|
|
|
|
I absolutely do not use VB, or VB.NET, my answer is based on my knowledge of the .NET framework. I suggest you look at the MSDN entries for the classes I pointed you to, they are bound to have a full example in VB.NET.
And security that isn't locked down so it can only be accessed via a stored procedure is not remotely secure
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi, I was wondering what you meant by "And security that isn't locked down so it can only be accessed via a stored procedure is not remotely secure"? Does that mean that stored procedures are more secure? and are they faster/give faster data retrieval results in large database applications?
|
|
|
|
|
Anonymous wrote:
Does that mean that stored procedures are more secure?
Absolutely. If your app uses plain SQL, then your user needs the right to arbitrarily execute SQL, which means that you open yourself to all sorts of attacks ( basically because the user has full access to the database ). If you use stored procedures, then give the user only the right to run a stored procedure, then they are unable to hack in a query that asks for all usernames and passwords, and instead can just run the stored procedure ( which returns true or false to a username/password combinatin passed in ).
Anonymous wrote:
are they faster/give faster data retrieval results in large database applications?
Yes, because they are precompiled ( so long as they are properly written )
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Depending on the size of the project I almost always start out using the Data Access Application Block for .NET they are free and will save you a ton of work. It is a great starting point to both learn from and get in the right habits for writing good code. In VB 6 there were a lot of public connections used however in .Net you will find a more defined seperation between the datalayer and the rest of your application.
">href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp">[">^]
Your question covers way to much to send in a message but let me try. In your case I would create a class objLogin, interface Ilogin, class dbLogin. Make the objLogin and dbLogin implement Ilogin that way they both have matching properties(this is the contract between objects) whenever you pass objLogin to dbLogin.
The application block is your database class and is very generic so whenever you create an instance of it in your dbLogin class it will create a connection object and command object the dbLogin object uses to access the database. I know this all sounds absurd but I have not written a Data Access Object in over a year now. I don't have to since it is generic and reusable I use the same one over and over. As for the rest of the objects once you get the hang of it they are easy to do.
I hope this helps point you in the right direction to find the answers you are looking for. Just remember to get the Data Access Application Blocks and hit a few articles on interfaces and you will be on your way. Oh yeah one more thing. Use Try Catch Finally in VB.net especially in your database classes or many bad things will happen to your app.
Good Luck
|
|
|
|
|
Thanks Mr KevinMac
The link u have given me was really useful.
I think i have to be working on some oops concepts before going into .net.
I used plain visual basic 6 and i found no difficulties in working with that.But when i started .net all look "Greek and Latin", and so i dont know where to start.
Am i need to use modules and classes the same way i do it vb6 and same way for forms etc..
SO all these made me really confused and i searched for articles which will give me some ideas how to begin but nothing there for begginers like me.
To be frank
"In your case I would create a class objLogin, interface Ilogin, class dbLogin. Make the objLogin and dbLogin implement Ilogin that way they both have matching properties(this is the contract between objects) whenever you pass objLogin to dbLogin.
"
I couldnt able to understand what it actually means.
So i expect a very basic level explanation, ( more like refering this from vb6 to vb.net mode)
Thank you very much mate for you helps
with regards
vimal
Help in need is the help indeed
|
|
|
|
|
I want to store xml file in a ntext datatype in sql server 2000, someone have any idea how to do this ?
By the way it's an XMLDocument who need to be stored and they are no more than 3-4k.
I have no idea on how to do that.. please help me !
I am a somehow a newbie
|
|
|
|
|
You could convert the document into a string and then store it in the database. May not be the most compact way of storing it, however.
|
|
|
|