|
I have no idea how your putting this information in the picturebox, but there's an easy solution. Resize the picturebox to as big as you need it, then put it inside a Panel control and set the Panel's AutoScroll property to True. Done!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Good Morning!
Wondering if anyone could enlighten me and possibly share some code as to how to report the install status of a specific update based on it's ID (ie: MS06-035 id:5915bac3-4cbd-4e1b-9ff1-8adc4188dd22) in VB.NET using the WSUS api.
Any help would be appreciated.
JCO
|
|
|
|
|
i work in database sql server 2000 and i need to encrypt password column so that and body open data base can not read passord
what code i use to do this
ma_refay
|
|
|
|
|
Ok, I hope this helps, SHA1 encryption, with my personal little twist:
And I made it as simple as possible, as all examples you'll find are messy and ugly..
For the encryption:
***************************************************************************
Imports System.Security.Cryptography
Imports System.Text
Imports System.Data
Imports System.Data.SqlClient
Function ComputePWD()
Dim HashValue() As Byte
Dim MessageString As String = [STRING TO ENCRYPT HERE]
Dim UE As New UnicodeEncoding()
Dim MessageBytes As Byte() = UE.GetBytes(MessageString)
Dim SHhash As New SHA1Managed()
HashValue = SHhash.ComputeHash(MessageBytes)
Dim pwd = ConvertBAToString(HashValue)
Return pwd
End Function
Function ConvertBAToString(ByVal HashValue)
Dim b As Byte
Dim converted As String = ""
For Each b In HashValue
converted = converted + b.ToString
Next b
Return converted
End Function
'copyright to ii_noname_ii@hotmail.com, pls keep this line :P
*************************************************************************
INFO:
[STRING TO ENCRYPT HERE] is what you wanna encrypt
"pwd" is your encrypted result returned by function toi call...
call is like this:
VAR = computePWD()
Tell me you love me if you use this... :P
*************************************************************************
Posting how to check for password, like a login in a reply to this....
|
|
|
|
|
A verify login example, for password encrypted like above:
(same imports needed) [] = you fill in!!!
*******************************************************************
Private Sub VerifyLogin()
Dim HashValue() As Byte
Dim MessageString As String = [Password.Text]
Dim UE As New UnicodeEncoding()
Dim MessageBytes As Byte() = UE.GetBytes(MessageString)
Dim SHhash As New SHA1Managed()
HashValue = SHhash.ComputeHash(MessageBytes)
Dim pwd = ConvertBAToString(HashValue)
Dim query = "SELECT COUNT(*) FROM [User] WHERE user_username=@Username AND user_password='" & pwd & "'"
Dim objConn As New SqlConnection("[Connection string!!!]")
Dim objCmd As New SqlCommand(query, objConn)
'''' ii_noname_ii@hotmail.com is your .net god!!! :P lol
'''' Copyrights for NoNaMe !! hehe
' Create parameters
Dim paramUsername As SqlParameter
paramUsername = New SqlParameter("@Username", SqlDbType.VarChar, 25)
paramUsername.Value = [UserName.Text]
objCmd.Parameters.Add(paramUsername)
'Insert the records into the database
objConn.Open()
Dim iResults As Integer = objCmd.ExecuteScalar()
objConn.Close()
'Display the hash value for tests only
'Dim b As Byte
'For Each b In HashValue
' Response.Write(b)
' Response.Write(" ")
'Next b
If iResults = 1 Then
'The user was found in the DB
'redirect to menu and set session id
'Response.Redirect("Default.htm")
[verfify worked]
Else
'The user was not found in the DB
[FailureText.Visible = True]
[verfify didn't work]
End If
End Sub
Function ConvertBAToString(ByVal HashValue)
Dim b As Byte
Dim converted As String = ""
For Each b In HashValue
converted = converted + b.ToString
Next b
Return converted
End Function
***********************************************************************
Some of the stuff in there must be filled or adapted to your use, but this should give you a strong head start.
Tell me you love me!!!
|
|
|
|
|
what version of VB you're using?
If you're using VB.NET or 2005 there are several way you can encrypt the password(string) before you commit it to the database.
You can try this one: (VB 2005)
--------------------------------------------------------------------------------
Imports System
Imports System.IO
Imports System.Text
Imports System.Security.Cryptography
Public Class CLSxCrypter
Private Enum ENUMxChains
e_Random = 0
e_Genuine = 1
End Enum
Private Shared SEC_Key() As Byte = {4, 79, 103, 140, 6, 60, 24, 88, _
76, 77, 254, 237, 104, 117, 106, 175, _
54, 140, 255, 30, 143, 61, 39, 19, _
122, 235, 123, 158, 250, 190, 159, 224}
Private Shared SEC_IV() As Byte = {110, 121, 68, 148, 141, 195, 221, 30, _
228, 89, 223, 131, 226, 82, 177, 195}
Public Shared Function SEC_Encrypt(ByVal xPlainString As String) As String
Dim EncryptBuffer() As Byte, _
EncryptedBytes() As Byte, _
EncryptedString As String = "", _
mRijndael As New RijndaelManaged, _
ASCIIConverter As New ASCIIEncoding, _
Encryptor As ICryptoTransform, _
msEncrypt As New MemoryStream
'create encryptor
Encryptor = mRijndael.CreateEncryptor(SEC_Key, SEC_IV)
'encrypt data
Dim csEncrypt As New CryptoStream(msEncrypt, Encryptor, CryptoStreamMode.Write)
'convert the data to a byte array
EncryptBuffer = ASCIIConverter.GetBytes(xPlainString)
'write all data to the crypto stream and flush it
csEncrypt.Write(EncryptBuffer, 0, EncryptBuffer.Length)
csEncrypt.FlushFinalBlock()
'get encrypted array of bytes
EncryptedBytes = msEncrypt.ToArray
'convert the encrypted bytes in array to string
For i As Integer = 0 To EncryptedBytes.Length - 1
EncryptedString = EncryptedString & EncryptedBytes(i) & " "
Next
EncryptedString = Left(EncryptedString, EncryptedString.Length - 1)
'return the encrypted string value
Return EncryptedString
End Function
Public Shared Function SEC_Decrypt(ByVal CipherString As String) As String
Dim EncryptedStrings() As String, _
EncryptedBytes() As Byte, _
DecryptBuffer() As Byte, _
DecryptedString As String, _
ASCIIConverter As New ASCIIEncoding, _
mRijndael As New RijndaelManaged, _
Decryptor As ICryptoTransform
'create decryptor
Decryptor = mRijndael.CreateDecryptor(SEC_Key, SEC_IV)
'convert the data to a byte array
EncryptedStrings = Split(CipherString)
ReDim EncryptedBytes(EncryptedStrings.Length - 1)
For i As Integer = 0 To EncryptedStrings.Length - 1
EncryptedBytes(i) = CByte(EncryptedStrings(i))
Next
'decrypt data
Dim msDecrypt As New MemoryStream(EncryptedBytes)
Dim csDecrypt As New CryptoStream(msDecrypt, Decryptor, CryptoStreamMode.Read)
DecryptBuffer = New Byte(EncryptedBytes.Length) {}
'Read the data out of the crypto stream
csDecrypt.Read(DecryptBuffer, 0, DecryptBuffer.Length)
'Convert the byte array back into a string
DecryptedString = ASCIIConverter.GetString(DecryptBuffer)
Return DecryptedString
End Function
-------------------------------------------------------------------------------
You can change the Key and IV with yours...
Good Luck
|
|
|
|
|
i need to add wav or mp3 file to my application and control to start or stop this file playing
ma_refay
|
|
|
|
|
i work in vb.net project and my database is sqlserver 2000 i need to make package to my project(setup project)
1- i need to add the database to setup package
2- i need to add the sql server to setup package and it run automatically if there is engine in the machine we install project on it
what the software i used to do that and how
thanks alot
ma_refay
|
|
|
|
|
Hi,
In my vb.net appliction, I use MsgBoxs...
example:
Dim msg = MsgBox("Are you sure you want to delete this learning?", 4100, "confirm delete")
If msg = 6 Then
(...)
(4100 is a yes no msgbox, always on top, useful MsgBox helper: http://www.autohotkey.com/docs/commands/MsgBox.htm[^])
Now the problem:
This msgbox is a deletion confirm from a large datagrid...
But while the MsgBox is on top, u can still click on the application under, which creates errors, for example, if u click the "edit" button, then click yes on msgbox...
How can i block application while msgbox is not clicked?
|
|
|
|
|
I have to question your us of the bit values when it's much easier to read an maintain the actual Enums used by thh MsgBox. Also, you're using the SystemModal attribute, which halts access to ALL applications in the system. Not very friendly, is it?
Use ApplicationModal instead and you'll get the result you want:
Dim mbr As MsgBoxResult
mbr = MsgBox("Are you sure?", MsgBoxStyle.YesNo Or MsgBoxStyle.ApplicationModal, "Confirm Delete")
If mbr = MsgBoxResult.Yes Then
...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I get 'MsgBoxResultmbr' is not defined...
|
|
|
|
|
Put this at the top of your code:
Imports Microsoft.VisualBasic
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
Why are you using MsgBox and not the MessageBox?
Select Case MessageBox.Show("Are you sure you want to delete this learning?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)<br />
Case Windows.Forms.DialogResult.Yes<br />
'Yes code here<br />
Case Windows.Forms.DialogResult.No<br />
'No code here<br />
End Select
Easier to read, and uses the .NET messagebox rather than the VB6- legacy MsgBox
Steve Jowett
|
|
|
|
|
I get "name MessageBox not declared" :s
|
|
|
|
|
Imports System.Windows.Forms
Thank should sort it.
Steve Jowett
|
|
|
|
|
Thanx!
|
|
|
|
|
My problem has to do with an OCX written in VB6, that is being hosted
by the MMC console (in an OCX result view).
How do I resize the OCX so that it fits correctly in the
parent/container? I want the OCX to fill up a portion of the container, and maintain that ratio when the MMC window is resized (or during initial load).
Any thoughts?
Thanks in advance
SivaKumar
|
|
|
|
|
Your OCX will have to expose some kind of Resize method. If not, you generally out of luck. You could try hacking around this by searching for the window that the OCX puts up, getting it's handle and then sending the appropriate window messages to get it to resize, but even then, if the support to draw itself using a resizable window is not there, this will all be for nothing.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
i m making a windows application and using treeview control.
i m making the treeview from database.
after doing the editing in text of treeview node.
i want to save the changes back in the database.
how can i do that?
thanx n regardz
kapil
|
|
|
|
|
The same way you built the treeview from the database. You'll have to walk through each node in the TreeView and build the appropriate SQL statements to update your database properly. There is no standard method to do this. Everything, including tracking which nodes go where, depends entirely on the capabilities you've built into your database.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
i trying to add info from user input n submit into the database
i use the insert into
--------------
Private Sub AddSubmitB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddSubmitB.Click
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Jasmine\My Documents\member\db1.mdb"
Dim cmd As New OleDb.OleDbCommand
Dim con As OleDb.OleDbConnection
Dim dr As OleDb.OleDbDataReader
Dim strsql As String
con = New OleDb.OleDbConnection(strcon)
con.Open()
strsql = "Insert into member(BorrowerId, Fname, Lname, Gender, Address1, Address2, Address3) values('" & BorrowerIdTB.Text & "',' " & FnameTB.Text & "',' " & LnameTB.Text & "','" & GenderCLB.Text & "',' " & Add1TB.Text & "','" & Add2TB.Text & "',' " & Add3TB.Text & "')"
cmd.Connection = con
cmd.CommandText = strsql
cmd.ExecuteNonQuery()
con.Close()
MsgBox("Record Added")
Me.Close()
End Sub
--------------
when i run it the debugger stopped at cmd.ExecuteNonQuery()
i seriously duno wat the error is about
|
|
|
|
|
It would help greatly if we knew what the error was!
But, as a suggestion to clean up your code and make it easier to maintain, you might want to look into using parameterize queries instead of this string concantenation mess you've created. This is most likely where your problem is origination from. You can read more about parameterized queries and why they're a much better way to go in Colin Mackay's excellent article here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
|