|
Hi friends,
i desprately need a method to do paging a Datalist(ASP.NET), that will be displaying data using SQLDataSource.
Any help?
:- Rashid Ali -:
|
|
|
|
|
You're asking this question in the wrong forum. You're looking for the ASP.NET[^] forum.
|
|
|
|
|
hello frnds,
i am using vb.Net 2.0 , i have developed a application which is add the custom variable and update it.
now , i want to update the variables by
objDoc.customDocumentsProperties("BlahBlah")="BlahBlah"
objDoc.fields.Update()
objDoc.Save()
and all the custom variables are updated EXCEPT the variables under the Header and footer are not gor updated ....WHY??
Where i am wrong ...Please tell
help....
regards,
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
Hi,
Currently I am able to drag and drop a single item at a time from a list box to another listbox, but I need to drag multiple items at a time. here is the code for dragging single item. just tell me how I can drag and drop multiple items between list boxes
//////////**************************////////////////////
Public Class Form1
Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim Lsstr1 As String = DirectCast(e.Data.GetData(DataFormats.StringFormat), String)
ListBox1.Items.Add(Lsstr1)
End If
End Sub
Private Sub ListBox1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragOver
e.Effect = DragDropEffects.All
End Sub
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
If ListBox1.Items.Count = 0 Then
Return
End If
Dim lsstring As String = ListBox1.Items(ListBox1.IndexFromPoint(e.X, e.Y)).ToString()
Dim lodde1 As DragDropEffects = DoDragDrop(lsstring, DragDropEffects.All)
If lodde1 = DragDropEffects.All Then
ListBox1.Items.RemoveAt(ListBox1.IndexFromPoint(e.X, e.Y))
End If
End Sub
Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim Lsstr1 As String = DirectCast(e.Data.GetData(DataFormats.StringFormat), String)
ListBox2.Items.Add(Lsstr1)
End If
End Sub
Private Sub ListBox2_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragOver
e.Effect = DragDropEffects.All
End Sub
Private Sub ListBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox2.MouseDown
If ListBox2.Items.Count = 0 Then
Return
End If
Dim ls As String = ListBox2.Items(ListBox2.IndexFromPoint(e.X, e.Y)).ToString()
Dim lodde1 As DragDropEffects = DoDragDrop(ls, DragDropEffects.All)
If lodde1 = DragDropEffects.All Then
ListBox2.Items.RemoveAt(ListBox2.IndexFromPoint(e.X, e.Y))
End If
End Sub
End Class
//////////////***********************///////////////////////////
Thanks and Regards,
sudhakar venati,
Mob: 0 984 55 989 71.
|
|
|
|
|
You need to change your code in the DragDrop event to cast the data to an array of strings, not just a single string. Then you need to iterate through the strings and add them to the ListBox:
Private Sub ListBox1_DragDrop(blah, blah) Handles ListBox1.DragDrop
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim Lsstr1 As String() = DirectCast(e.Data.GetData(DataFormats.StringFormat), String())
For Each item As String In Lsstr1
ListBox1.Items.Add(item)
Next
End If
End Sub
|
|
|
|
|
Private Sub ListBox1_DragDrop(blah, blah) Handles ListBox1.DragDrop If e.Data.GetDataPresent(DataFormats.StringFormat) Then Dim Lsstr1 As String() = DirectCast(e.Data.GetData(DataFormats.StringFormat), String()) For Each item As String In Lsstr1 ListBox1.Items.Add(item) Next End IfEnd Sub
your logic is not working for multiple selections, if I select and move multiple items from one list box to another list box, there I am able to view only one string 4 times iteration
Thanks and Regards,
sudhakar venati,
Mob: 0 984 55 989 71.
|
|
|
|
|
That's because the code is written for strings. I tested it using drag and drop of multiple files from Explorer.
You'll have to modify your code to put the appropriate item types into the Data object and pull those same item types out of the Data object. If you're posting and array of Object items to the drag, you have to pull the same array of Object item types off, not an array of Strings.
Post the code you're using to populate the drag.
|
|
|
|
|
Many many thanks for your interest.
Here is the code where I am passing a string to dodragdrop() function.Please make the needfull changes to this code.
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
If ListBox1.Items.Count = 0 Then
Return
End If
Dim lsstring As String = ListBox1.Items(ListBox1.IndexFromPoint(e.X, e.Y)).ToString()
Dim lodde1 As DragDropEffects =DoDragDrop(lsstring,DragDropEffects.All)
If lodde1 = DragDropEffects.All Then
ListBox1.Items.RemoveAt(ListBox1.IndexFromPoint(e.X, e.Y))
End If
End Sub
/************** here is the entire code of sample project************///
Public Class Form1
Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim Lsstr1 As String = DirectCast(e.Data.GetData(DataFormats.StringFormat), String)
ListBox1.Items.Add(Lsstr1)
End If
End Sub
Private Sub ListBox1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragOver
e.Effect = DragDropEffects.All
End Sub
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
If ListBox1.Items.Count = 0 Then
Return
End If
Dim lsstring As String = ListBox1.Items(ListBox1.IndexFromPoint(e.X, e.Y)).ToString()
Dim lodde1 As DragDropEffects = DoDragDrop(lsstring, DragDropEffects.All)
If lodde1 = DragDropEffects.All Then
ListBox1.Items.RemoveAt(ListBox1.IndexFromPoint(e.X, e.Y))
End If
End Sub
Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim Lsstr1 As String = DirectCast(e.Data.GetData(DataFormats.StringFormat), String)
ListBox2.Items.Add(Lsstr1)
End If
End Sub
Private Sub ListBox2_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragOver
e.Effect = DragDropEffects.All
End Sub
Private Sub ListBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox2.MouseDown
If ListBox2.Items.Count = 0 Then
Return
End If
Dim ls As String = ListBox2.Items(ListBox2.IndexFromPoint(e.X, e.Y)).ToString()
Dim lodde1 As DragDropEffects = DoDragDrop(ls, DragDropEffects.All)
If lodde1 = DragDropEffects.All Then
ListBox2.Items.RemoveAt(ListBox2.IndexFromPoint(e.X, e.Y))
End If
End Sub
End Class
Thanks and Regards,
sudhakar venati,
Mob: 0 984 55 989 71.
|
|
|
|
|
Ummm...Your're not populating the DragDrop with the strings at all. You're just removing the items from the source list box! There's nothing in the Drop because you didn't put anything into it!
You have to start a Drag and Drop operation by populating the data being transerfered with the ListBox's DoDragDrop[^] method.
|
|
|
|
|
Dim str1 As String
str1 = " "
Dim i As Integer
i = 0
Dim intag As Boolean
intag = False
Dim thetag As String
thetag = " "
Dim htmlinput As String
htmlinput = TextBox1.Text
Dim tempchar As String
Const a As String = "ControlChars.Tab"
For i = 0 To htmlinput.Length() - 1
tempchar = htmlinput.Chars(i)
If (tempchar.Equals("<")) Then
intag = True
thetag = ""
tempchar = ""
ElseIf (tempchar.Equals(">")) Then
intag = False
tempchar = ""
ElseIf (tempchar.Equals(" ")) Then
tempchar = ""
End If
If (intag) Then
thetag += tempchar
ElseIf (thetag.Equals("td")) Then
str1 += tempchar + " "
thetag = ""
ElseIf (thetag.Equals("tr")) Then
str1 += tempchar + " "
thetag = ""
ElseIf (thetag.Equals("\n")) Then
str1 += tempchar
thetag = ""
Else
str1 += tempchar
End If
Next
TextBox2.Text = str1
i have a file txt file with following text
now i want to display the txt file code in another textbox as this is displayed in a html file.
my code at the top has a certain mistake. which i am not able to rectify.
could any one help
there is no such thing as good or bad.
|
|
|
|
|
Why do you think that there is a problem with the code?
What is it supposed to do?
---
single minded; short sighted; long gone;
|
|
|
|
|
Missing Indentation.
|
|
|
|
|
my code is not helping me to display as it would be displayed in a html page. but it is displaying as it is from the text file
ie i want my code to display the text file as
row one col one
row two col two
but my code is displaying like this
row one
col one
row two
col two
there is no such thing as good or bad.
|
|
|
|
|
"\n" doesn't have any meaning in VB.NET. Replace it with Environment.NewLine and it might work, or ControlChars.Cr , or ControlChars.Lf , or ControlChars.CrLf , just to make sure you get all the possible carriage returns and line feeds.
|
|
|
|
|
Dave is on the right track, however Environment.NewLine or ControlChars.CrLf won't work as you are looking at a single character at a time.
A line break consists of a carriage return and a line feed. You have to compare against both ControlChars.Cr and ControlChars.Lf to handle both of the characters.
---
single minded; short sighted; long gone;
|
|
|
|
|
Whoops! I haven't had my Coke yet this morning.
|
|
|
|
|
Putting comments in your code would be helpful. Helps give some idea of what is going on
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi
I have the following function for returning a user specific salt using a stored procedure in mySQL
But my code doesn't seem to be returning a value from my OUTput parameter, can anyone see a problem
Cheers
code is
Sub getSalt(ByVal sender As Object, ByVal e As EventArgs)
'Create connection string to pass database, string holds login information to mySQL,
Dim connectionString As String
connectionString = "Server=localhost; uid=;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
'Set command string to equal SPROC
cmdString.CommandText = "sp_getSalt"
'ONLY PLACE THIS IF SPROC, sets the command to a SPROC
cmdString.CommandType = CommandType.StoredProcedure
Dim literr As New LiteralControl
Dim param As MySqlParameter
Try
param = cmdString.Parameters.Add("?p_salt", MySqlDbType.VarChar)
cmdString.Parameters("?p_salt").Direction = ParameterDirection.Output
Dim salt As String = cmdString.Parameters("?p_salt").Value
sendData(sender, e, salt)
Catch ex As Exception
literr.Text = ex.Message
MsgBox(ex.Message)
End Try
Procedure is
CREATE DEFINER=`jshort`@`localhost` PROCEDURE `sp_getSalt`(IN p_userName VARCHAR(20), OUT p_salt varchar(500))
BEGIN
SELECT salt INTO p_salt FROM Users WHERE UserName = p_UserName;
END
|
|
|
|
|
Perhaps if you tried to actually execute the procedure...
---
single minded; short sighted; long gone;
|
|
|
|
|
i know i jus realised how retarded i was, it is also helpful if I passed the username into it as well...
But it still doesn't work
Correct me if my reasonin is wrong here
when i create a user i provide them with a random salt
Then when i encrpyt the password, i also add the salt into that encryption, so providing a unique password (yes/no?)
When i log in
I get the application to grab the users salt based on the username entered
I then need to do the same process as before of taking the username entered and using the salt i retrieved, and encrpyting them again
and this should *in theory* be the same password as stored
but it doesn't seem to work like this, so i am takin my reasoning is fatally flawed somewhere
|
|
|
|
|
No, that's correct. The problem could be in how you stored the salt. What you created your salt and added it to the password, are you getting back the EXACT same salt out of the database just before you add it to the entered password attempt?
|
|
|
|
|
I have checked that by gettin it display the value in messagebox's and it returns the same salt value which is commited to the database each time
|
|
|
|
|
this is the code that i use to create the salt
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 = encoder.GetString(data)
MsgBox(PSalt)
i then do the following to encrypt my password and i just pass the psalt variable into my salt field in database
hashedBytes = shaHash.ComputeHash(encoder.GetBytes(txtPassword.Text & PSalt))
Dim PWhash As String = encoder.GetString(hashedBytes)
param = cmdString.Parameters.Add("?p_Password", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = PWhash
MsgBox(PWhash)
to log in I have the following function which gets my salt
cmdStringS.CommandText = "sp_getSalt"
cmdStringS.CommandType = CommandType.StoredProcedure
Dim literr As New LiteralControl
Dim param As MySqlParameter
Try
param = cmdStringS.Parameters.Add("?p_username", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtUserName.Text
param = cmdStringS.Parameters.Add("?p_salt", MySqlDbType.VarChar)
cmdStringS.Parameters("?p_salt").Direction = ParameterDirection.Output
connection.Open()
cmdStringS.ExecuteScalar()
connection.Close()
Catch ex As Exception
literr.Text = ex.Message
MsgBox(ex.Message)
End Try
Dim salted As String = cmdStringS.Parameters("?p_salt").Value
sendData(sender, e, cmdStringS, salted)
I then pass salted variable to my data submit method, where i do the followin wit the password and hash
hashedBytes = shaHash.ComputeHash(encoder.GetBytes(txtPassword.Text & salted))
Dim PWhash As String = encoder.GetString(hashedBytes)
param = cmdString.Parameters.Add("?p_Password", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = PWhash
|
|
|
|
|
Hmmm...I can't really see anything wrong with it. I've done similar stuff in the past, but instead of using UTF8 encoding to convert the salt to a string, I converted it to a Base64 string and added that you the password.
I've always generated the salt in a seperate function, generated the salted password hash in another...
Private Function GenerateSalt(ByVal size As Integer) As String
' The drop dead minumum useful salt size is 5 bytes, and
' a max of 12 would generate a string of 8 to 20 Base64 characters.
size = Math.Min(Math.Max(5, size), 12)
Dim rng As New RNGCryptoServiceProvider()
Dim buffer(size) As Byte
rng.GetBytes(buffer)
Return Convert.ToBase64String(buffer)
End Function
Private Function GenerateSaltedPasswordHash(ByVal password As String, ByVal salt As String) As String
' This section is GREATLY simplified. I normally do something MUCH more
' wicked to combine the password and salt, and hash it. Of course, I'm not saying what...
Dim saltedPassword As String = password & salt
Dim SHA As New SHA512Managed
Dim buffer() As Byte = Encoding.UTF8.GetBytes(saltedPassword)
Return Convert.ToBase64String(SHA.ComputeHash(buffer))
End Function
Why do I use Base64 so much?? Easy. The return values are suitable for storage on/in ANY medium. XML files, any database, any file, ...
This version of the function would generate a password hash string about 80 to 100 characters long. Your milage may vary. This length of password may or may NOT be acceptable to you. Consider the situation where you may have 60,000,000 users. That's a password column containing 6GB of data, not counting the salt storage, or any other user data.
|
|
|
|
|
boyindie wrote: Dim data() As Byte
data = New Byte(6) {}
Dim rng As New RNGCryptoServiceProvider
rng.GetBytes(data)
Dim PSalt As String = encoder.GetString(data)
That's not a good way to create a random string. The random bytes that you create might not correspond to actual characters in that encoding. Also, as some characters are encoded into more than one byte, you might create a byte patten that ends in a half character.
Just start with a non-random string like "asdf" until you have got the rest of the code working.
param = cmdString.Parameters.Add("?p_Password", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = PWhash
Unless you have set up your database to use unicode, it will not be able to store any unicode characters.
There is no code to actually store anything in the database. Is it missing, or did you just omit it?
cmdStringS.ExecuteScalar()
Why are you using ExecuteScalar, when you don't read anything from the result? Use ExecuteNonQuery instead.
---
single minded; short sighted; long gone;
|
|
|
|
|