|
Maybe you already figured it out, but a char in vb is something like
Dim c as Char = "("c
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
A good reference for parsing code (or whatever) is in Compilers, Principles techniques and Tools (aka The Dragon Book) by Aho, Sethi and Ullman, c. 198x?
...Steve
|
|
|
|
|
ahem..
Anybody knows how to use/connect an OpenDocument Database (OPEN-OFFICE DB), to VB.NET. ?
This is no emergency.
Thanks.!
Marvin N. Guerrero
- Taje Kage_bunshinNunJutsU
|
|
|
|
|
Is there an ODBC driver for it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Guerven wrote: This is no emergency.
Sorry I don't know the answer, but full marks for stating this in your post!
...Steve
|
|
|
|
|
i want to select one row from one datagrid which is binding to a dataset, then click add button to add this row into the datagrid below, how to implement this ??
emergency!! so everyone pls help me!!
I am Entry level person
|
|
|
|
|
maxiachun wrote: i want to select one row from one datagrid which is binding to a dataset, then click add button to add this row into the datagrid below, how to implement this ??
Seems fairly straight forward to me. What is the problem you are experiencing? Elaborate more and you may get a sensible answer.
maxiachun wrote: emergency!! so everyone pls help me!!
What sort of emergency? If this is for a uni project/homework etc, sorry but you've come to the wrong place.
...Steve
|
|
|
|
|
hehe! i need a bit help becoz i have problem in Currency manager binding! so i want someone to give me some advice!
I am Entry level person
|
|
|
|
|
here is some code!
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
If cnn.State = ConnectionState.Closed Then
cnn.Open()
da.Fill(ds.ProductTable)
dv = New DataView(ds.ProductTable)
cm = CType(Me.BindingContext(Me.ds, "ProductTable"), CurrencyManager)
If System.IO.File.Exists(sFile) Then
Me.Prizes1.ReadXml(sFile)
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
cnn.Close()
End Try
End Sub
Private Sub BtnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSearch.Click
Dim strFilter As String = "PLU_Number > 0"
If txtCode.Text.Length > 0 Then
strFilter = strFilter & "and Inventory_Code like '" & txtCode.Text & "%'"
End If
If txtPLU.Text.Length > 0 Then
strFilter = strFilter & "and PLU_Number like '" & txtPLU.Text & "%'"
End If
If txtDescription.Text.Length > 0 Then
strFilter = strFilter & "and Description like '" & txtDescription.Text & "%'"
End If
dv.RowFilter = strFilter
DataGrid1.DataSource = dv
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim dr As Prizes.PrizeTableRow
Try
With CType(cm.Current.row, ds.ProductTableRow)
dr = Me.Prizes1.PrizeTable.NewRow()
dr.Inventory_Code = .Inventory_Code
dr.Qty = 1
dr.Awarded = 0
Me.Prizes1.PrizeTable.Rows.Add(dr)
End With
Catch ex As Exception
End Try
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Me.Prizes1.WriteXml(sFile)
End Sub
End Class
I am Entry level person
|
|
|
|
|
maxiachun wrote: here is some code!
Ok I see the code but what is the problem?
On what line are you getting an exception or is it just not working as you expected?
I'm not going to analyze it for you. Make it easy for me and I'll help.
...Steve
|
|
|
|
|
maxiachun wrote: Dim strFilter As String = "PLU_Number > 0"
If txtCode.Text.Length > 0 Then
strFilter = strFilter & "and Inventory_Code like '" & txtCode.Text & "%'"
Here's an issue. You need a space after the 0, otherwise it looks like this:
PLU_Number > 0and Inventory_Code like etc.
Looking at the values in the debugger is a good way to find errors like this one, and always trailing a space if you must build SQL like this is another. Of course, you shouldn't build your SQL like this, for starters, if this is a real world app, you're wide open to injection attacks.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
so what is the solution for building SQL how to do??
I am Entry level person
|
|
|
|
|
Well, at a bare minimum you should check the text for quotes, so that the string coming in doesn't close the quotes ( which is how an injection attack occurs ). There's at least one article here on CP about this, search for 'SQL injection' to find it.
Even if you use stored procs instead of building SQL, you're vunerable if you don't clean your input first.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Steve Pullan wrote: What sort of emergency?
There seems to be a growing trend of people with no skillset being asked to write code by their employers, and coming here for help. It's not their fault, really, it's the employers fault.
But you're right, it's equally possible he wants us to do his homework. I'd be happy to help him though, if he can demonstrate that he's tried to tackle the problem himself.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote: There seems to be a growing trend of people with no skillset being asked to write code by their employers, and coming here for help. It's not their fault, really, it's the employers fault.
But you're right, it's equally possible he wants us to do his homework. I'd be happy to help him though, if he can demonstrate that he's tried to tackle the problem himself.
Yep, I agree on all counts. My last reply (probably as you were writing this one to me) was a bit abrupt, but all I got was some source code. I'm not going to analyze anyone's code unless there is evidence that he/she has done some work and provided a decent description of the problem. Call me old fashioned
It saddens me that untrained people are actually cutting code. Part of the problem of such high level tools that make it easier I guess - and employers' expectations.
I'm glad you have more patience than me .
Anyway - back to lurking... Cheers
...Steve
|
|
|
|
|
Steve Pullan wrote: Call me old fashioned
No, I agree totally.
Steve Pullan wrote: t saddens me that untrained people are actually cutting code.
Yeah, I think it's a sign that employers are valuing what we do as being worth less and less. Not wanting to ignite the language wars, but it's definately more the case with VB than C++. In fact, I did a job in C# ( a video jukebox ) and the client would not consider C++ and was really keen on VB ( I refused the job in VB, due to personal preference ), because VB coders are 'cheap and easy to find', and that because 'VB is easy'. It's only a matter of time before this end of the market makes no more money than a bank teller or checkout chick, because the tools ARE easier, and sites like this one make it easier again.
Steve Pullan wrote: Part of the problem of such high level tools that make it easier I guess - and employers' expectations.
Yeah, it's both of those things. And for the record, I don't expect C# to be much different in a few years time. I still love C# though, especially with the C# 2.0 ( and 3.0 ) stuff that I've seen. There will always be people willing to hack code for $10 an hour, but the people who employ those folks will get the systems they deserve, and pay the price when we're called in to fix them. I know, I've done it on some VB/ASP.NET sites already.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Anyway thank you for you two's help!
i have just learned this for one and half months, i do need some help in certain field! if i really know how to manage all the objects and functions in VS.net , i also can solve the problem by myself. i am here becoz i need some experienced people to teach me new things andgive me some idea. if someone want to help i really appreciate it. VB.net is really like a designer, there is not many thinking things in it, once you have done something then you are able to do it! expirience is the key here. i put my problem here coz i have never seen this kind of problem then i need help and i want to develop my future on this. i won't use anyone else's code to make money for myself.
I am Entry level person
|
|
|
|
|
thank you anyway! i donot need someone to teach me a lesson! i just want to learn something through here! and i know you are very good but it does not mean you can judge person here! maybe i misunderstand you, but i just donot feel good since i am trying to learn here!
I am Entry level person
|
|
|
|
|
maxiachun wrote: thank you anyway! i donot need someone to teach me a lesson! i just want to learn something through here! and i know you are very good but it does not mean you can judge person here! maybe i misunderstand you, but i just donot feel good since i am trying to learn here!
Please re-read my original replies to your question and you'll see that I WAS trying to help. It took me at least two replies to get anything meaningful from you about this problem of yours.
Like I said in the beginning - the more information you can give about the problem in the first place makes it easier for us as more experienced developers to provide you with the correct level of help. Simply giving us source code to analyze and debug is not good enough - you must provide sufficient information for us to help you.
This may sound a bit harsh but we get varying degrees of help requests here - from homework to real-world problems - and in the recent past the homework guys have been peppering the board with useless and unresearched questions. To be quite frank, I thought your question was in the same boat, but I tried to help anyway!
I wish you all the best sorting out this problem.
...Steve
|
|
|
|
|
anyway i have done it! thank you i was trying to let you understand me!
I am Entry level person
|
|
|
|
|
I have 2 tables (banks and rates) prepared in access database and these tables are connected through inner join.
The bank columns are (bankID and bankname) and Rates columns are (RateID, bankID, Monthnumber, CommissionRate).
I want to make a table on which I want display only the Bankname and the MonthNumber with Commissionrate related with this (bankID). When there is a change with the commission rate I should be able to update it on this table. If a bank should be added I should also be able to add or delete Bank and MonthNumber and Commissionrate accordingly. To sum up, I want to apply insert - update and delete operations on database which filled in datagrid.
I thank in advance to those who can help me.
|
|
|
|
|
I am encrypting some text using RC2 encryption in the database.
Encryption works fine.
Problem is decrypting it. When i try to decrypt it, it is throwing bad data exception.
Can anyone help?
|
|
|
|
|
Well, you can have about 100 things wrong. Your problem can be in your encryption and/or decryption code or in the database save/retrieve code. Without seeing any of this stuff, it's impossible to tell you what's wrong.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Here is the Encrypt and Decrypt functions
Public Sub New()
mobjCrypto = New RC2CryptoServiceProvider
'//Generate the key. //
mobjCrypto.GenerateKey()
'// Assign the key to the byt variable. //
bytCryptoKey = mobjCrypto.Key
'// Generate a random initialization vector (IV) to be used for the algorithm. //
mobjCrypto.GenerateIV()
bytCryptoIV = mobjCrypto.IV
'// Prepare the Encryptor and Decryptor objects. //
mCryptoEncryptor = mobjCrypto.CreateEncryptor(bytCryptoKey, bytCryptoIV)
mCryptoDecryptor = mobjCrypto.CreateDecryptor(bytCryptoKey, bytCryptoIV)
mobjCrypto.Mode = CipherMode.CBC
End Sub
Public Function Encrypt(ByVal TextToEncrypt As String) As String
Dim strEncryptedData As String
Dim bytEncryptedData As Byte()
Dim bytPlainText As Byte()
Try
'// Create the memory stream. Encryption process will take place here instead of writing into a file. //
Dim msEncrypt As MemoryStream = New MemoryStream
'// Convert the text into byte form in preperation to be encrypted. //
bytPlainText = mTextConverter.GetBytes(TextToEncrypt)
'// Create the CryptoStream that ties together the MemoryStream and the ICryptoTransform. //
Dim csEncrypt As CryptoStream = New CryptoStream(msEncrypt, mCryptoEncryptor, CryptoStreamMode.Write)
'// Write the bytPlainText out to the CryptoStream and flush it. //
csEncrypt.Write(bytPlainText, 0, bytPlainText.Length)
'// Flush the CryptoStream so that nothing remains in the buffer. //
csEncrypt.Flush()
'// close the CryptoStream
csEncrypt.Close()
'// Get the encrypted text from the MemoryStream .I can't simply just grab the string because the stream doesn't work that way. //
bytEncryptedData = msEncrypt.ToArray()
'// Close the MemoryStream. //
msEncrypt.Close()
'// Convert the EncryptedDataBytes array into a base64 string. i.e. into a readable format. //
strEncryptedData = System.Convert.ToBase64String(bytEncryptedData)
Return (strEncryptedData)
Catch ex As Exception
Dim intExceptionNumber As Integer
End Try
End Function
Public Function Decrypt(ByVal EncryptedText As String) As String
Dim bytEncryptedData As Byte()
Dim bytDecryptedData As Byte()
Dim strDecryptedText As String
Try
'// Convert EncryptedText into a byte array to assign to the MemoryStream. //
bytEncryptedData = System.Convert.FromBase64String(EncryptedText)
' Create the memory stream which will hold the decrypted text. //
Dim msDecrypt As MemoryStream = New MemoryStream(bytEncryptedData)
'// Create the CryptoStream that ties together the MemoryStream and the ICryptoTransform. //
Dim csDecrypt As CryptoStream = New CryptoStream(msDecrypt, mCryptoDecryptor, CryptoStreamMode.Read)
bytDecryptedData = New Byte(bytEncryptedData.Length) {}
'// Read the data out of the crypto stream. //
csDecrypt.Read(bytDecryptedData, 0, bytDecryptedData.Length)
'// Flush and close the CryptoStream. //
csDecrypt.Flush()
csDecrypt.Close()
'// Close the memory stream. //
msDecrypt.Close()
'// Convert the byte array back into a string. //
strDecryptedText = mTextConverter.GetString(bytDecryptedData)
Return (strDecryptedText)
Catch ex As Exception
Dim intExceptionNumber As Integer
End Try
End Function
I am storing data after encrypting it and after retrieving it from the database trying to decrypt it.
Now the problem is that when i try to decrypt it
csDecrypt.Read(bytDecryptedData, 0, bytDecryptedData.Length)
it give Bad data as exception
Where am i wrong?
|
|
|
|
|
nitin_ion wrote: bytDecryptedData = New Byte(bytEncryptedData.Length) {}
'// Read the data out of the crypto stream. //
csDecrypt.Read(bytDecryptedData, 0, bytDecryptedData.Length)
'// Flush and close the CryptoStream. //
csDecrypt.Flush()
csDecrypt.Close()
One of the parameters to csDecrypt.Read() is wrong. My guess is that bytDecryptedData.Length should be bytEncryptedData.Length.
...Steve
|
|
|
|