|
Do you have a sample of your code where you think it should be working?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I want to be able to force a system rightclick. Is there a way to do that?
|
|
|
|
|
yes. try to use the "keys" properties.
|
|
|
|
|
First, you're going to have to describe what you mean by a "system right-click".
|
|
|
|
|
I want to force a right-click so my program will bring up the contextmenu.
|
|
|
|
|
So call the Show method on the ContextMenu you want to show. You don't need to "force a right-click".
|
|
|
|
|
Hi
I have created a create user login function
which creates a random salt for each individual user and stores it into my mySQL database along with a salted hashed password
I enter all the data into my database thru a stored procedure
i keep on getting an odd error
That my procedure expected 7 parameters and only received 6
Altho my code is definetly passing 7 parameters accross to the database, on debuggin the parameter count is also equal to 7, it doesn't make sense, probably somthin stupid
can anyone see the problem
Cheers
Boy
my procedure is
CREATE DEFINER=`jshort`@`localhost` PROCEDURE `sp_myinsertUsers`(IN p_userName varchar(20), IN p_password varchar(200),IN p_salt varchar(200),IN p_firstName varchar(20), IN p_lastname varchar(200),IN p_phone integer(12), IN p_mail varchar(200))
BEGIN
INSERT INTO users(userName,Password,salt,user_firstName, user_lastName, user_phone,user_mail)VALUES(p_username, p_password,p_salt, p_firstname, p_lastname, p_phone, p_mail)
;
END
my code is as follows
Sub send_loginCreds(ByVal sender As Object, ByVal e As EventArgs)
Dim litErr As New LiteralControl
Dim shaHash As New System.Security.Cryptography.SHA384Managed()
Dim hashedBytes As Byte()
Dim encoder As New UTF8Encoding()
Dim data() As Byte
data = New Byte(6) {}
Dim rng As New RNGCryptoServiceProvider
rng.GetBytes(data)
Dim PSalt As String = Convert.ToBase64String(data)
'Create connection string to pass database, string holds login information to mySQL,
Dim connectionString As String
connectionString = "Server=localhost; ;database=ftp1;"
'Builds .net mysql connection and passes connection string into method
Dim connection As New MySqlConnection(connectionString)
'Create mySql command string for passing query or SPROC(Stored Procedure)
Dim cmdString As New MySqlCommand
'Set Command to equal mySql connection,t so can pass SQL query
cmdString.Connection = connection
Try
'Set command string to equal SPROC
cmdString.CommandText = "sp_myInsertusers"
'ONLY PLACE THIS IF SPROC, sets the command to a SPROC
cmdString.CommandType = CommandType.StoredProcedure
Dim param As New MySqlParameter
param = cmdString.Parameters.Add("?p_username", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtFirstName.Text
'encrypt(password)
hashedBytes = shaHash.ComputeHash(encoder.GetBytes(txtPassword.Text))
Dim PWhash As String = encoder.GetString(hashedBytes)
param = cmdString.Parameters.Add("?p_Password", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = PWhash
param = cmdString.Parameters.Add("?p_salt", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = PSalt
param = cmdString.Parameters.Add("?p_firstname", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtFirstName.Text
param = cmdString.Parameters.Add("?p_lastname", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtLastName.Text
param = cmdString.Parameters.Add("?p_phone", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtPhone.Text
param = cmdString.Parameters.Add("?p_mail", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtMail.Text
'Insert the records into the database
connection.Open()
cmdString.ExecuteNonQuery()
connection.Close()
Catch ex As Exception
litErr.Text = ex.Message
MsgBox(ex.Message)
End Try
Server.Transfer("userhome.aspx")
End Sub
|
|
|
|
|
boyindie wrote: 'encrypt(password)
hashedBytes = shaHash.ComputeHash(encoder.GetBytes(txtPassword.Text))
Dim PWhash As String = encoder.GetString(hashedBytes)
param = cmdString.Parameters.Add("?p_Password", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = PWhash
Might be the problem. In your stored proc it is p_password, and in the vb code is it p_Password. Not sure if it is case sensitive or not.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
No,
I think it has somthin to do with my salt, as it was all working perfectly until i put the code for creating, converting and passing my salt value into database
|
|
|
|
|
Is the string PSalt staying under 200 characters in length?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Are any of the parameter values an empty string??
|
|
|
|
|
Discovered problem, the actual value of my salt field in database wasn't long nuff for some reason had it only set to 50.
Been at this too long i thinks, although i now have my page working
Cheers People
|
|
|
|
|
Glad it sounds like you got it figured out
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
well no1 whose got a girlfriend is goin to be hacking my passwords anytime soon
|
|
|
|
|
I noticed you were using SHA384 , and that should be plenty sufficient for some time
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I'm working on my first vb.Net project I have a field that is not required, but is numeric. If the user leaves the field blank I get the following error, when I try to use it set a value in my object.
InvalidCastException: Cast from string "" to type 'Integer' is not valid.]
Here is the code.
MyShelled.KC = Me.txtKC.Text
Here is the object's property
Public WriteOnly Property KC() As Integer
Set(ByVal NewVal As Integer)
MyKC = NewVal
End Set
End Property
I've tried to create overloaded properties but I get the following compile error.
c:\inetpub\wwwroot\Shelling\clsZebra.vb(228): 'Public Overloads WriteOnly Property KC() As Integer' and 'Public Overloads WriteOnly Property KC() As String' cannot overload each other because they differ only by return types.
I'd like to handle this in my class but I'm not sure how to go about. Any direction would be great.
Thanks
Travis
|
|
|
|
|
If Not IsNothing(Me.txtKC.Text) AndAlso me.txtKC.text.trim <> String.Empty Then
MyShelled.KC = Me.txtKC.Text
End If
|
|
|
|
|
FYI, to handle in your class, you would need to define your property as an object so that it can accept different datatypes like strings and numbers, etc. then filter out anything you don't want to allow like empty strings, etc.
|
|
|
|
|
mymacryan wrote: MyShelled.KC = Me.txtKC.Text
This happens because VB is weakly typed ( aka sucks ). You need to set a default value if the string is empty. One way to do this is to pretend it's strongly typed and use int.TryParse to see if you get an int out of it, and otherwise set a default. This has the advantage of not assuming your presentation layer has only allowed numbers to be entered.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian,
I'm curious...
he has his property set as type 'integer' you can set a default value on that where you send an empty string to the property and the default will be applied instead of throwing an exception?
how do you do that?
|
|
|
|
|
|
When i run my application, backgroundworker starts. Then i stop it by exiting the sub and when i try to start it again, it says backgroundWorker is busy.
How can i reset the Background Worker so it can start again? (.CancelAsync doesent work)
|
|
|
|
|
set this property to true when you first setup the variable for the backgroundworker then the cancel will work
Worker.WorkerSupportsCancellation
|
|
|
|
|
i forgot to mention it was already set to true. It stops fine, it's only when i want to restart that it gives me an exception.
here is part of the code: (cancellation support is already set to true)
Private Sub stopdwlbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles stopdwlbut.Click
Me.bgworker1.CancelAsync()
End Sub
Private Sub bgworker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgworker1.DoWork
For Y = 1 To numsites
'does what i want it to do
If Me.bgworker1.CancellationPending Then
e.Cancel = True
CType(bgworker1, BackgroundWorker).ReportProgress(0)
Exit Do
End If
End Sub
Private Sub bgworker1_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bgworker1.ProgressChanged
If e.ProgressPercentage = 0 Then
Downloadbut.Enabled = True
stopdwlbut.Enabled = False
MsgBox("download canceled")
Else
'does something else
End If
End Sub
|
|
|
|
|
then reset it...
worker.dispose
worker = nothing
worker = new backgroundworker
|
|
|
|