|
take a look [herewww.behzadi.net
|
|
|
|
|
Hi,
I want to know wat is the limit on the total number of checkboxes created in a checkedBoxList. Is there any limit to the total number of checkboxes generated?If my dataset is returning 1000 values then will my checkedboxlist generate 1000 checkboxes?
Thanks,
Riz
|
|
|
|
|
Hi,
Yes it will generate 1000 checkboxes.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Of course, No limit on no.of check boxes.
gh
|
|
|
|
|
Hi all,
i try to put one image in a table. right now the table is empty.i insert image through front end web form by selecting specified image on clicking browse button.after click the insert button then this error is raised. how can i solve this.
"System.IndexOutOfRangeException: There is no row at position 0 "
pls help me.
|
|
|
|
|
Could you please post your code too??
I believe, you are updating the 0th row of the DataSet without adding NewRow to it. As the table is empty, the 0th row does not exists. But this is my assumption.
Post your code, lets analyze it...
|
|
|
|
|
hi venkatesh,
you are right, u r assumption is correct. but i want to insert many rows from webform. but this code inserts only one row.if try to insert many rows overwrite and show latest insert record. how to solve this.
my code:
Dim da As New SqlDataAdapter("Select * From pub_info ", con)
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
con.Open()
da.Fill(ds, "pub_info")
Dim fn As String = System.IO.Path.GetFullPath(File1.PostedFile.FileName)
Dim fs As New FileStream(fn, FileMode.OpenOrCreate, FileAccess.Read)
Dim MyData(fs.Length) As Byte
Dim sql As String
fs.Read(MyData, 0, fs.Length)
fs.Close()
ds.Tables("pub_info").Rows(0)("logo") = MyData
da.Update(ds, "pub_info")
pls help me.
|
|
|
|
|
Sophia Rekhi wrote: Dim da As New SqlDataAdapter("Select * From pub_info ", con)
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
con.Open()
da.Fill(ds, "pub_info")
Dim fn As String = System.IO.Path.GetFullPath(File1.PostedFile.FileName)
Dim fs As New FileStream(fn, FileMode.OpenOrCreate, FileAccess.Read)
Dim MyData(fs.Length) As Byte
Dim sql As String
fs.Read(MyData, 0, fs.Length)
fs.Close()
ds.Tables("pub_info").Rows(0)("logo") = MyData
da.Update(ds, "pub_info")
Change as below,
Dim da As New SqlDataAdapter("Select * From pub_info ", con)
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
con.Open()
da.Fill(ds, "pub_info")
Dim fn As String = System.IO.Path.GetFullPath(File1.PostedFile.FileName)
Dim fs As New FileStream(fn, FileMode.OpenOrCreate, FileAccess.Read)
Dim MyData(fs.Length) As Byte
Dim sql As String
fs.Read(MyData, 0, fs.Length)
fs.Close()
If ds.Tables("pub_info").Rows.Count=0 Then
Dim DR As DataRow = ds.Tables("pub_info").NewRow()
ds.Tables("pub_info").Rows.Add(DR)
End If
ds.Tables("pub_info").Rows(0)("logo") = MyData
da.Update(ds, "pub_info")
I think this would solve your problem.
|
|
|
|
|
Thanx venkatesh,
it is fine , while i click insert button.but no image is stored in to table.and after clicking the getimage button same error will raise.
but your solutions is very helpful to me.
thanks
|
|
|
|
|
Sophia Rekhi wrote: it is fine , while i click insert button.but no image is stored in to table.and after clicking the getimage button same error will raise.
I don't know how you are implementing this. But I can explain my code,
* Selects the record from the table
* Checks whether it has record
* If no rocord, add a row and update the 0th row
* Else just update the 0th row.
Its seems you are adding only one image to the table. Why can't your try FileSystem instead of DB?
|
|
|
|
|
If Not IsPostBack Then
'Dim Str As String
'Str = txtusername.Text
'If Not objDatabase Is Nothing And Not Is Nothing Then
'End If
If Not Request.Cookies("UserInfo") Is Nothing Then
txtusername.Text = Request.Cookies("UserInfo")("UserName").ToString()
txtpassword.Attributes.Add("value", Request.Cookies("UserInfo")("Password").ToString())
End If
End If
End Sub
Private Sub butuser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butuser.Click
Dim username As String
Dim password1 As String
Dim checkbox As String
username = txtusername.Text
password1 = txtpassword.Text
If (chkplayer.Checked = True) Then
Dim objCookie As New HttpCookie("UserInfo")
objCookie.Values.Add("UserName", txtusername.Text)
objCookie.Values.Add("Password", txtpassword.Text)
objCookie.Expires = DateTime.Now.AddDays(1)
'this is for one day
Response.Cookies.Clear()
Response.Cookies.Add(objCookie)
End If
this my code how can i encrypt the cookies
regards
saravanan
|
|
|
|
|
|
Public Shared Function encrypt(ByVal val As String, ByVal seed As Byte()) As String
Dim KEY_64 As Byte()
KEY_64 = seed
Dim IV_64 As Byte() = New Byte(7) {55, 103, 246, 79, 36, 99, _
167, 3}
If val <> "" Then
Dim cryptoProvider As New DESCryptoServiceProvider
Dim ms As New MemoryStream
Dim cs As New CryptoStream(ms, cryptoProvider.CreateEncryptor(KEY_64, IV_64), CryptoStreamMode.Write)
Dim sw As New StreamWriter(cs)
sw.Write(val)
sw.Flush()
cs.FlushFinalBlock()
ms.Flush()
Return Convert.ToBase64String(ms.GetBuffer(), 0, Convert.ToInt32(ms.Length))
End If
Return ""
End Function
Public Shared Function decrypt(ByVal val As String, ByVal seed As String) As String
Dim KEY_64 As Byte() = Convert.FromBase64String(seed)
Dim IV_64 As Byte() = New Byte(7) {55, 103, 246, 79, 36, 99, _
167, 3}
If val <> "" Then
Dim cryptoProvider As New DESCryptoServiceProvider
Dim buffer As Byte() = Convert.FromBase64String(val)
Dim ms As New MemoryStream(buffer)
Dim cs As New CryptoStream(ms, cryptoProvider.CreateDecryptor(KEY_64, IV_64), CryptoStreamMode.Read)
Dim sr As New StreamReader(cs)
Return sr.ReadToEnd()
End If
Return ""
End Function
Public Shared Function CreateSalt(ByVal size As Integer) As Byte()
' Generate a cryptographic random number using the cryptographic service provider
Dim rng As New RNGCryptoServiceProvider
Dim buff As Byte() = New Byte(size - 1) {}
rng.GetBytes(buff)
' Return a Base64 string representation of the random number
Return buff
End Function
Private Sub butuser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butuser.Click
Dim username As String
Dim password As String
Dim checkbox As String
username = txtusername.Text
password = txtpassword.Text
If username <> "" Then
'if Username is not null
Dim salt As Array
salt = CreateSalt(8)
username = encrypt(username, salt)
'encrypting the password to salt 8 algorithm
username = username.Replace("'", "''")
End If
If password <> "" Then
Dim salt As Array
'if password is not null
salt = CreateSalt(8)
password = encrypt(password, salt)
'encrypting the password to salt 8 algorithm
password = password.Replace("'", "''")
End If
If (chkplayer.Checked = True) Then
Dim objCookie As New HttpCookie("UserInfo")
objCookie.Values.Add("UserName", username)
objCookie.Values.Add("Password", password)
objCookie.Expires = DateTime.Now.AddDays(1)
'this is for one day
Response.Cookies.Clear()
Response.Cookies.Add(objCookie)
End If
Dim conn As SqlConnection = New SqlConnection("server=Wafes10;database=lgateway;uid=;pwd=;Trusted_connection=true")
conn.Open()
Dim cmd As SqlCommand = New SqlCommand("select count (*) from register where uname='" + txtusername.Text + "' and password='" + txtpassword.Text + "'", conn)
Dim dr As SqlDataReader
dr = cmd.ExecuteReader
dr.Read()
Dim rowcount As String
rowcount = dr(0).ToString
dr.Close()
hi i used this code encrypted sucessfully
how can i decript the username,password saved in cookies
|
|
|
|
|
saravanan05 wrote: hi i used this code encrypted sucessfully
how can i decript the username,password saved in cookies
Good Great All the best Happy Coding
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
hi
i encrypeted sucessfully
the username and password saved in encryped form in cookies
how can i decrypt that username,password
I use this code only
Public Shared Function encrypt(ByVal val As String, ByVal seed As Byte()) As String
Dim KEY_64 As Byte()
KEY_64 = seed
Dim IV_64 As Byte() = New Byte(7) {55, 103, 246, 79, 36, 99, _
167, 3}
If val <> "" Then
Dim cryptoProvider As New DESCryptoServiceProvider
Dim ms As New MemoryStream
Dim cs As New CryptoStream(ms, cryptoProvider.CreateEncryptor(KEY_64, IV_64), CryptoStreamMode.Write)
Dim sw As New StreamWriter(cs)
sw.Write(val)
sw.Flush()
cs.FlushFinalBlock()
ms.Flush()
Return Convert.ToBase64String(ms.GetBuffer(), 0, Convert.ToInt32(ms.Length))
End If
Return ""
End Function
Public Shared Function decrypt(ByVal val As String, ByVal seed As String) As String
Dim KEY_64 As Byte() = Convert.FromBase64String(seed)
Dim IV_64 As Byte() = New Byte(7) {55, 103, 246, 79, 36, 99, _
167, 3}
If val <> "" Then
Dim cryptoProvider As New DESCryptoServiceProvider
Dim buffer As Byte() = Convert.FromBase64String(val)
Dim ms As New MemoryStream(buffer)
Dim cs As New CryptoStream(ms, cryptoProvider.CreateDecryptor(KEY_64, IV_64), CryptoStreamMode.Read)
Dim sr As New StreamReader(cs)
Return sr.ReadToEnd()
End If
Return ""
End Function
Public Shared Function CreateSalt(ByVal size As Integer) As Byte()
' Generate a cryptographic random number using the cryptographic service provider
Dim rng As New RNGCryptoServiceProvider
Dim buff As Byte() = New Byte(size - 1) {}
rng.GetBytes(buff)
' Return a Base64 string representation of the random number
Return buff
End Function
Private Sub butuser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butuser.Click
Dim username As String
Dim password As String
Dim checkbox As String
username = txtusername.Text
password = txtpassword.Text
If username <> "" Then
'if Username is not null
Dim salt As Array
salt = CreateSalt(8)
username = encrypt(username, salt)
'encrypting the password to salt 8 algorithm
username = username.Replace("'", "''")
End If
If password <> "" Then
Dim salt As Array
'if password is not null
salt = CreateSalt(8)
password = encrypt(password, salt)
'encrypting the password to salt 8 algorithm
password = password.Replace("'", "''")
End If
regards
saravanan
|
|
|
|
|
It is Amazing that you have done this much of work.
saravanan05 wrote: how can i decript the username,password saved in cookies
Get it[^]
Regards,
Satips.
|
|
|
|
|
hi satips
i encrypeted sucessfully
the username and password saved in encryped form in cookies
how can i decrypt that username,password
I use this code only
Public Shared Function encrypt(ByVal val As String, ByVal seed As Byte()) As String
Dim KEY_64 As Byte()
KEY_64 = seed
Dim IV_64 As Byte() = New Byte(7) {55, 103, 246, 79, 36, 99, _
167, 3}
If val <> "" Then
Dim cryptoProvider As New DESCryptoServiceProvider
Dim ms As New MemoryStream
Dim cs As New CryptoStream(ms, cryptoProvider.CreateEncryptor(KEY_64, IV_64), CryptoStreamMode.Write)
Dim sw As New StreamWriter(cs)
sw.Write(val)
sw.Flush()
cs.FlushFinalBlock()
ms.Flush()
Return Convert.ToBase64String(ms.GetBuffer(), 0, Convert.ToInt32(ms.Length))
End If
Return ""
End Function
Public Shared Function decrypt(ByVal val As String, ByVal seed As String) As String
Dim KEY_64 As Byte() = Convert.FromBase64String(seed)
Dim IV_64 As Byte() = New Byte(7) {55, 103, 246, 79, 36, 99, _
167, 3}
If val <> "" Then
Dim cryptoProvider As New DESCryptoServiceProvider
Dim buffer As Byte() = Convert.FromBase64String(val)
Dim ms As New MemoryStream(buffer)
Dim cs As New CryptoStream(ms, cryptoProvider.CreateDecryptor(KEY_64, IV_64), CryptoStreamMode.Read)
Dim sr As New StreamReader(cs)
Return sr.ReadToEnd()
End If
Return ""
End Function
Public Shared Function CreateSalt(ByVal size As Integer) As Byte()
' Generate a cryptographic random number using the cryptographic service provider
Dim rng As New RNGCryptoServiceProvider
Dim buff As Byte() = New Byte(size - 1) {}
rng.GetBytes(buff)
' Return a Base64 string representation of the random number
Return buff
End Function
Private Sub butuser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butuser.Click
Dim username As String
Dim password As String
Dim checkbox As String
username = txtusername.Text
password = txtpassword.Text
If username <> "" Then
'if Username is not null
Dim salt As Array
salt = CreateSalt(8)
username = encrypt(username, salt)
'encrypting the password to salt 8 algorithm
username = username.Replace("'", "''")
End If
If password <> "" Then
Dim salt As Array
'if password is not null
salt = CreateSalt(8)
password = encrypt(password, salt)
'encrypting the password to salt 8 algorithm
password = password.Replace("'", "''")
End If
regards
saravanan
|
|
|
|
|
saravanan05 wrote: i encrypeted sucessfully
the username and password saved in encryped form in cookies
Good.
saravanan05 wrote: how can i decrypt that username,password
What error it shows when you decrypt.
Let me know it in detail.
Regards,
Satips.
|
|
|
|
|
hi satips
this is my function in decrypt
Public Shared Function decrypt(ByVal val As String, ByVal seed As String) As String
Dim KEY_64 As Byte() = Convert.FromBase64String(seed)
Dim IV_64 As Byte() = New Byte(7) {55, 103, 246, 79, 36, 99, _
167, 3}
If val <> "" Then
Dim cryptoProvider As New DESCryptoServiceProvider
Dim buffer As Byte() = Convert.FromBase64String(val)
Dim ms As New MemoryStream(buffer)
Dim cs As New CryptoStream(ms, cryptoProvider.CreateDecryptor(KEY_64, IV_64), CryptoStreamMode.Read)
Dim sr As New StreamReader(cs)
Return sr.ReadToEnd()
End If
Return ""
End Function
here i wrote code for retrive the uname,password from cookies in page load
If Not IsPostBack Then
If Not Request.Cookies("UserInfo") Is Nothing Then
Dim username As String
Dim password As String
Dim checkbox As String
Dim salt As String
'salt = Convert.ToInt32(CreateSalt(8))
' username = decrypt(txtusername.Text = Request.Cookies("UserInfo")("UserName").ToString(), Convert.ToInt32(salt))
'txtusername.Text = Request.Cookies("UserInfo")("UserName").ToString()
txtusername.Text = (Request.Cookies("UserInfo")("UserName").ToString())
txtpassword.Attributes.Add("value", Request.Cookies("UserInfo")("Password").ToString())
End If
well,how can i call the decrypt function here
regards
saravanan
|
|
|
|
|
saravanan05 wrote: how can i call the decrypt function here
How you called in Encrypting ?
Likewise call it.
Regards,
Satips.
|
|
|
|
|
hi
i called same this it is not working
can u help me
regards
saravanan
|
|
|
|
|
Try again and Again dont wait for our answers.
Regards,
Satips.
|
|
|
|
|
|
Cool anwser..It may be boosting saravanan
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
|