|
hi, guys i have function for get multi values from a datareader
is working fine but when i have two or more data only i can get the las register
how i can get all register ??
Public Class OracleDataClass
Public ORAVALUEA As String
Public ORAVALUEB As String
Public ORAVALUEC As String
Public ORAVALUED As String
End Class
Function OracleQuerys(ByVal orasql_query As String, ByVal ORAVALUEA As String, ByVal ORAVALUEB As String, ByVal ORAVALUEC As String, ByVal ORAVALUED As String) As OracleDataClass
Try
Dim OracleGetInfo As New OracleDataClass
Dim OracleDataClass As
orasql_querys = orasql_query
oracle_cmd_command = New OracleCommand(orasql_query, conoracle)
oracle_data_reader = oracle_cmd_command.ExecuteReader
While (oracle_data_reader.Read())
OracleGetInfo.ORAVALUEA = oracle_data_reader.Item(ORAVALUEA)
OracleGetInfo.ORAVALUEB = oracle_data_reader.Item(ORAVALUEB)
OracleGetInfo.ORAVALUEC = oracle_data_reader.Item(ORAVALUEC)
OracleGetInfo.ORAVALUED = oracle_data_reader.Item(ORAVALUED)
End While
Return OracleGetInfo
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
oracle_data_reader.Close()
End Function
Dim GetDataOracle As OracleDataClass = OracleQuerys(orasql_query, ORAVALUEA, ORAVALUEB, ORAVALUEC, ORAVALUED)
client_product_number = GetDataOracle.ORAVALUEB
client_phone_number = GetDataOracle.ORAVALUEC
thanks for the help and time
|
|
|
|
|
Yes, that will onyl return the last value read because you're storing every single value in the same single-valued variables, overwriting the values from the previous pass through your While loop.
You have to use some List variant or arrays to return more than one set of values.
|
|
|
|
|
ok nice i will use a Array thanks
|
|
|
|
|
look this my array
Function OracleQuerys(ByVal orasql_query As String, ByVal ORAVALUEA As String, ByVal ORAVALUEB As String, ByVal ORAVALUEC As String, ByVal ORAVALUED As String) As ArrayList
Try
Dim OracleGetInfo As ArrayList = New ArrayList
orasql_querys = orasql_query
oracle_cmd_command = New OracleCommand(orasql_query, conoracle)
oracle_data_reader = oracle_cmd_command.ExecuteReader
While oracle_data_reader.Read()
OracleGetInfo.Add(oracle_data_reader(ORAVALUEA))
OracleGetInfo.Add(oracle_data_reader(ORAVALUEB))
OracleGetInfo.Add(oracle_data_reader(ORAVALUEC))
OracleGetInfo.Add(oracle_data_reader(ORAVALUED))
End While
Return OracleGetInfo
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
oracle_data_reader.Close()
End Function
i get the Data in the fills but how i can pass for example to varible call Name? on on ORAVALUEA
Thanks for your time and help
|
|
|
|
|
You REALLY need to pickup a beginners book on C#. You're just guessing at how this stuff works and wondering why it doesn't. You don't have the faintest idea of how these basic constucts work.
Create a class or structure to hold the items for one record. Then you can add that to a List and return that instead.
|
|
|
|
|
ok, dude thanks for your time and help.. i will check the book
thanks alot!
|
|
|
|
|
I Have A Form Called Invoice And Has A Data grid view That Contains The Details Of the Specific Invoice
One Field In The Invoice Details Data grid view Called ItemIndex
So When user Enters An UnExisted ItemIndex An Error occurs With Message "Item Not Found" So I Created Another Form When This Error Occurs A Form Called Item List Opens With A List Of The Available Items So When The User Clicks On An Item The Info In That Specific Row Should Be Transferred to Invoice Details Datgridview In The Invoice Form
The Item Index Form Can Be Called From More Than One Form In The Application As The Item Index Help
Can Be Requested From Purchased Or Transfer Forms.....
Can Anyone Help With This Issue Please ?????
Many Thanks In Advance
|
|
|
|
|
BTW it's pretty rough to understand what you mean at all. Why not use punctuation and normal writing style to make it easier for someone who wants to help???
As far as I understand you want to transfer a row from one DataGridView to another. I didn't test that, but – assuming they have the same set of columns – I'd consider to transfer the relevant row from the DateGridView's DataSource (dataset / table) to the other grids DataSource.
|
|
|
|
|
I Have Solved The Problem
How:
In Form Form1
[CODE]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MySearchForm As Form2
MySearchForm = New Form2()
MySearchForm.txtSearch.Text = txtsearchCriteria.Text
If MySearchForm.ShowDialog() <> DialogResult.OK Then
Return
End If
TextBox1.Text = MySearchForm.MySearch.STCODE
TextBox2.Text = MySearchForm.MySearch.STDESC
TextBox3.Text = MySearchForm.MySearch.STSELA
TextBox3.Text = MySearchForm.MySearch.STSELC
TextBox4.Text = MySearchForm.MySearch.STSELO
MySearchForm = Nothing
End Sub
[/Code]
In Form2
[CODE]
Public MySearch As New clsStock 'A Public Class Created To Collect Info From Specific Query
Private Sub gvStock_RowHeaderMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles gvStock.RowHeaderMouseDoubleClick
With MySearch
.STCODE = gvStock.Rows(e.RowIndex).Cells("STCODE").Value
.STSELA = gvStock.Rows(e.RowIndex).Cells("STSELA").Value
.STSELB = gvStock.Rows(e.RowIndex).Cells("STSELB").Value
.STSELC = gvStock.Rows(e.RowIndex).Cells("STSELC").Value
.STSELO = gvStock.Rows(e.RowIndex).Cells("STSELO").Value
End With
End Sub
[/Code]
I Hope Everyone Would Benefit from it
wahid kalo
|
|
|
|
|
Quote: Private Sub txtLunch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtLunch.TextChanged
If Not String.IsNullOrEmpty(txtLunch.Text) Then
If txtLunch.Text >= 0 Then
Lunch = txtLunch.Text
SubFnB = Breakfast + Lunch + Dinner + Supper + Snack + Beverage + Grocerries
txtSubFnB.Text = SubFnB
End If
End If
End Sub
Private Sub txtDinner_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDinner.TextChanged
If Not String.IsNullOrEmpty(txtDinner.Text) Then
If txtDinner.Text >= 0 Then
Dinner = txtDinner.Text
SubFnB = Breakfast + Lunch + Dinner + Supper + Snack + Beverage + Grocerries
txtSubFnB.Text = SubFnB
End If
End If
End Sub
Private Sub txtSupper_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSupper.TextChanged
If Not String.IsNullOrEmpty(txtSupper.Text) Then
If txtSupper.Text >= 0 Then
Supper = txtSupper.Text
SubFnB = Breakfast + Lunch + Dinner + Supper + Snack + Beverage + Grocerries
txtSubFnB.Text = SubFnB
End If
End If
End Sub
Private Sub txtSnack_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSnack.TextChanged
If Not String.IsNullOrEmpty(txtSnack.Text) Then
If txtSnack.Text >= 0 Then
Snack = txtSnack.Text
SubFnB = Breakfast + Lunch + Dinner + Supper + Snack + Beverage + Grocerries
txtSubFnB.Text = SubFnB
End If
End If
End Sub
Private Sub txtBeverage_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBeverage.TextChanged
If Not String.IsNullOrEmpty(txtBeverage.Text) Then
If txtBeverage.Text >= 0 Then
Beverage = txtBeverage.Text
SubFnB = Breakfast + Lunch + Dinner + Supper + Snack + Beverage + Grocerries
txtSubFnB.Text = SubFnB
End If
End If
End Sub
Private Sub txtGroceries_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtGroceries.TextChanged
If Not String.IsNullOrEmpty(txtGroceries.Text) Then
If txtGroceries.Text >= 0 Then
Grocerries = txtGroceries.Text
SubFnB = Breakfast + Lunch + Dinner + Supper + Snack + Beverage + Grocerries
txtSubFnB.Text = SubFnB
End If
End If
End Sub
Private Sub txtAllowance_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAllowance.TextChanged
If Not String.IsNullOrEmpty(txtAllowance.Text) Then
If txtAllowance.Text >= 0 Then
Allowance = txtAllowance.Text
End If
End If
End Sub
Private Sub txtSubFnB_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSubFnB.TextChanged
If Not String.IsNullOrEmpty(txtSubFnB.Text) Then
If txtSubFnB.Text >= 0 Then
SubFnB = txtSubFnB.Text
Total = SubFnB
txtTotalUsage.Text = Total
txtWalletCash.Text = Wallet
Wallet = (Wallet + Allowance) - Total
End If
End If
End Sub
Sorry for asking so many things.
My SubFnB is displayed correctly but my wallet isn't.
It keeps on multiplying the total
How to fix this?
|
|
|
|
|
Okay, I've solve it myself by assigning the wallet calculation to another variable.
|
|
|
|
|
Hello,
My VB.NET application currently securely downloads a username and password required to access a web service that contains sensitive data. The problem I face now is storing that username and password on-disk in a secure manner for future use.
I've looked into various encryption algorithms etc. but all involve storing some kind of key for decryption locally (rendering the encryption a bit of a joke) or hard-coding the key into the application (difficult-to-maintain and just about as useful as the last option). I welcome any suggestions as to how relatively secure local storage of a username and password might be accomplished. Despite hours of wracking my brains poking about in the System.Security.Cryptography namespace I'm no closer to finding a solution than I was at the start.
SixOfTheClock
A programming language is to a programmer what a fine hat is to one who is fond of fancy garden parties. Just don't try wearing any .NET language on your head. Some of them are sharp.
modified 2-Sep-12 5:18am.
|
|
|
|
|
Not the answer you're going to want to hear, but it can't really be done.
If you really want it to be secure, you'll have to require the user to enter a master password. Other popular programs do this too. Typically, you will be given the option of encrypting multiple passwords using one master password (most secure) or encrypting the passwords using a built-in key (which would be stored in plain text somewhere).
You could also use multiple layers of indirection (e.g., a config setting that points to a file that stores the path the encryption key is stored in) to make it harder for somebody to obtain the encryption key, but it's not really any more secure (just harder to access).
|
|
|
|
|
Ah, I thought as much. I'll take a look into these options, thank you very much indeed!
A programming language is to a programmer what a fine hat is to one who is fond of fancy garden parties. Just don't try wearing any .NET language on your head. Some of them are sharp.
|
|
|
|
|
actually you can. The solution, however, is in using a .NET secure string for the password and store the secure string in a file. Take a look(bing it) at how to use secure strings with powershell, if you're using win 7 then it should be a piece of cake.
L. Carlos Rodriguez
DCU, LLC
Braselton, GA 30517
|
|
|
|
|
..and there is me reading the file, and shouting your password in the streets. Any other solutions?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
...there's nothing better than making passwords public so you can shout them to the world, that's why we use the.NET secure string functionality for batch files protections at both the DOL and Treasury. But then again, this is the government and we don't know what we're doing....
Sorry I led you in the wrong path....
Good luck
|
|
|
|
|
dcu.lcr wrote: ...there's nothing better than making passwords public so you can shout them to the world, that's why we use the.NET secure string functionality for batch files protections at both the DOL and Treasury.
For batch files?
Let me rephrase that; any secret that's stored, isn't.
dcu.lcr wrote: But then again, this is the government and we don't know what we're doing....
You working for the government is not an argument, nor does it validate your statement.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Simplest solution is to NOT store it locally. Store it on your (web)server, and have your app request it when required.
(That's still no guarantee that no-one will duplicate the sensitive data btw)
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Very sensible idea there, and very true about the sensitive data. If the point of my application is to search through and display said sensitive data then it would be impossible to completely secure for that very reason. Thank you for your reply, this seems like a better way to go about it and is well worth testing out.
A programming language is to a programmer what a fine hat is to one who is fond of fancy garden parties. Just don't try wearing any .NET language on your head. Some of them are sharp.
|
|
|
|
|
You're welcome
|
|
|
|
|
Whatever method you use I also like to have a set of "red herring" credentials - that looks likes a password, - e.g. config setting Password with some cyrptic looking string that could be an encrypted string - sends the b'rs of on a wild goose chase
|
|
|
|
|
Another way to make things that little bit more difficult to figure out for anyone with mischief on their mind. Excellent thank you.
SixOfTheClock
A programming language is to a programmer what a fine hat is to one who is fond of fancy garden parties. Just don't try wearing any .NET language on your head. Some of them are sharp.
|
|
|
|
|
|
If the app can access it (required, otherwise it could not use the data), then so can I
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|