|
|
And what about performance using the file contents on these cases :
- Saving the file on a folder
- Using FileStream
- Saving on a VARBINARY(MAX) fields.
( Of course supposing that the file may be on whatever size ).
|
|
|
|
|
In the second link I posted, there are some measurements in the end. Have a look at those.
|
|
|
|
|
I prefer streaming files in database. In many cases it payed back - specially in backups.
|
|
|
|
|
where can I read more about it , and is this method suitable for large files ?
|
|
|
|
|
I worked mostly with pictures with up to 4MB, but tried up to 1GB files (MySQL). Pay attantion to setting of database to allow large files.
|
|
|
|
|
ok , but where can I read more about this method ?
|
|
|
|
|
I´ve learned a lot from here:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4630&lngWId=10
|
|
|
|
|
Hello !
On a VB.net application , how can I find some information about SQL server ( programmatically within the vb.net program )
- IF sql server is installed and currently running ( on a given Pc name or network path ).
- If is a SQL server or a SQL server Express
- If Sql server is installed with a default instance or has a named instance.
- Find the Instance name( if available )
- If a database exist or no in a sql server
Thank you !
|
|
|
|
|
An easy way is to use SqlDataSourceEnumerator . You can use GetDataSources[^] method which should return
- server name
- instance name
- version
What comes to a database existence, you need to succesfully open a connection to the SQL Server instance in order to get that information. You basically have two possible approaches
- use a login that has necessary privileges to query for example sys.databases[^]
- try to open a connection to a predefined database and see if it fails or not.
|
|
|
|
|
- Sorry but the article on your link speak only for SQL server 2000 and 2005. Does it work for other sql server versions ?
- and what about my first questions , so how can I check if Sql server is installed and is running on a given PC name or network Path ?
Thank you !
|
|
|
|
|
As far as I know, it should work with newer installations.
The enumaration is done by communicating with SQL Browser. So it needs to be on in order to find the instance. If SQL Server and SQL Browser are stopped, this won't work.
Another way to do this is to use SMO and use SmoApplication.EnumAvailableSqlServers[^].
However, to ensure if the SQL Server is installed on a computer even if the services are down, I guess you need to contact the server and run for example a WMI query to find out if the program is installed or not. For this you would query Win32_Product[^] class.
|
|
|
|
|
Pls i need help in creating a report in vb.net using crystal report or any reporting platform available.
thanks
|
|
|
|
|
You never said what exactly you're having a problem with.
|
|
|
|
|
do you really want to do reporting in crystal reports?
|
|
|
|
|
I try to use reflection to get a list of member fields in a form class.
Public Class BaseForm
Inherits System.Windows.Forms.Form
......
Friend WithEvents MnuBaseFile As System.Windows.Forms.MenuItem
Friend WithEvents MnuBaseWindow As System.Windows.Forms.MenuItem
Friend WithEvents MnuBaseFileExit As System.Windows.Forms.MenuItem
Friend WithEvents BaseFormTimer As System.Timers.Timer
Friend WithEvents MenuMainSeparator1 As System.Windows.Forms.MenuItem
Friend WithEvents HelpProvider As System.Windows.Forms.HelpProvider
.....
Dim fi As System.Reflection.FieldInfo() = My.Forms.BaseForm.GetType().GetFields()
But I failed, the length of fi is zero, the fi is empty array.
|
|
|
|
|
The GetFields method with no parameters returns only public fields. Try using the other overload and specifying what you want to search for by defining the binding flags. For example:
Dim fi As System.Reflection.FieldInfo() = My.Forms.BaseForm.GetType().GetFields(BindingFlags.NonPublic Or BindingFlags.Instance)
For more information, see: Type.GetFields Method (BindingFlags)[^] and BindingFlags Enumeration[^]
|
|
|
|
|
|
You're welcome
|
|
|
|
|
i would like to know if it is possible to translate my code according to a database(currently using microsoft sql server)
the code i have it is encrypting and decryption on a file inside the microsoft visual studio project
i want to connect it to the database
[code]
~ Form1.vb ~ by HazardEdit // HazardEdit.com // youtube.com/HazardEdit
Imports System.Net.Mail
Public Class Form1
Public Const WM_NCLBUTTONDOWN As Integer = &HA1
Public Const HT_CAPTION As Integer = &H2
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
Private Declare Function ReleaseCapture Lib "user32.dll" () As Int32
Dim encdec As EncryptDecrypt
Dim passc As String
Dim userc As String
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
Close()
End Sub
Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
reg_form.Visible = True
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If filethere(TextBox1.Text & "\username.login") = True And filethere(TextBox1.Text & "\password.login") Then
Dim userreader As New System.IO.StreamReader(TextBox1.Text & "\username.login")
TextBox3.Text = userreader.ReadToEnd
TextBox3.Text = encdec.Decrypt(TextBox3.Text)
userreader.Close()
Dim passreader As New System.IO.StreamReader(TextBox1.Text & "\password.login")
TextBox4.Text = passreader.ReadToEnd
TextBox4.Text = encdec.Decrypt(TextBox4.Text)
passreader.Close()
If TextBox3.Text = TextBox1.Text And TextBox4.Text = TextBox2.Text Then
Dim smtp As New SmtpClient
Dim message As New MailMessage
smtp.Host = "smtp.gmail.com"
smtp.EnableSsl = True
smtp.Port = 587
smtp.Credentials = New Net.NetworkCredential("click.noreply@gmail.com", "ER8GD1F62BX16VXXD54T")
message.To.Add("f319782@rmqkr.net")
message.From = New MailAddress("click@gmail.com")
message.Subject = ("Logged in:" & TimeString & " | " & DateString)
message.Body = ("Logged in:" & TimeString & " | " & DateString)
MsgBox("You are now succesfully logged in!")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
Else
MsgBox("Error! Username or password is wrong!")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End If
Else
MsgBox("This user doesn't exist!")
End If
End Sub
Function filethere(ByVal filename As String) As Boolean
If (Dir(filename) = "") Then
filethere = False
Else
filethere = True
End If
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.MouseDown
End Sub
Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown, Panel1.Paint
If (e.Button = Windows.Forms.MouseButtons.Left) Then
ReleaseCapture()
SendMessage(Handle.ToInt32, WM_NCLBUTTONDOWN, HT_CAPTION, 0)
End If
End Sub
Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs)
End Sub
End Class
' ~ EncryptDecrypt.vb ~ by HazardEdit // HazardEdit.com // youtube.com/HazardEdit
Public Class EncryptDecrypt
Public Shared Function Encrypt(ByVal text_to_Encrypt As String) As String
Dim encstr As String = text_to_Encrypt
Dim Val As String = Nothing
Dim Result As New System.Text.StringBuilder
For Each Character As Byte In System.Text.ASCIIEncoding.ASCII.GetBytes(text_to_Encrypt)
Result.Append(Convert.ToString(Character, 2).PadLeft(8, "0"))
Result.Append(" ")
Next
Val = Result.ToString.Substring(0, Result.ToString.Length - 1)
encstr = Val
Dim ret As String = converttoline(encstr)
Return ret
End Function
Public Shared Function Decrypt(ByVal Text_to_Decrypt As String) As String
Dim decret As String = Text_to_Decrypt
decret = converttoline(decret)
Dim Val As String = Nothing
Dim Characters As String = System.Text.RegularExpressions.Regex.Replace(decret, "[^01]", "")
Dim ByteArray((Characters.Length / 8) - 1) As Byte
For Index As Integer = 0 To ByteArray.Length - 1
ByteArray(Index) = Convert.ToByte(Characters.Substring(Index * 8, 8), 2)
Next
Val = System.Text.ASCIIEncoding.ASCII.GetString(ByteArray)
decret = Val
Return decret
End Function
Private Shared Function converttoline(ByVal text_to_convert As String) As String
Dim str As String = text_to_convert
' If str.Contains("É9;$,c#¾˜xžïw;½ƒÏ+ÃNòcñçâ32½ƒhâÏ+v½ƒÏ+a½ƒÏ+pŒ¿") Or str.Contains("š\NÌ;F÷¯G¥<ò3 ¥®;$,c#äÇ*hâÐ!4½ƒÏ+xžïw;64ÃNw1MÙñçŒfvnîÃÄ!Xì{™") Then
If str.Contains("|") Then
str = str.Replace(" || ", "0")
str = str.Replace(" | ", "1")
'str = str.Replace("š\NÌ;F÷¯G¥<ò3 ¥®;$,c#äÇ*hâÐ!4½ƒÏ+xžïw;64ÃNw1MÙñçŒfvnîÃÄ!Xì{™", "0")
' str = str.Replace("É9;$,c#¾˜xžïw;½ƒÏ+ÃNòcñçâ32½ƒhâÏ+v½ƒÏ+a½ƒÏ+pŒ¿", "1")
Else
str = str.Replace("0", " || ")
str = str.Replace("1", " | ")
' str = str.Replace("0", "š\NÌ;F÷¯G¥<ò3 ¥®;$,c#äÇ*hâÐ!4½ƒÏ+xžïw;64ÃNw1MÙñçŒfvnîÃÄ!Xì{™")
' str = str.Replace("1", "É9;$,c#¾˜xžïw;½ƒÏ+ÃNòcñçâ32½ƒhâÏ+v½ƒÏ+a½ƒÏ+pŒ¿")
End If
Return str
End Function
End Class
' ~ register_form.vb ~ by HazardEdit // HazardEdit.com // youtube.com/HazardEdit
Imports System.Net.Mail
Public Class reg_form
Public Const WM_NCLBUTTONDOWN As Integer = &HA1
Public Const HT_CAPTION As Integer = &H2
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
Private Declare Function ReleaseCapture Lib "user32.dll" () As Int32
Dim encdec As ClassLibrary1.EncryptDecrypt
Dim passc As String
Dim userc As String
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
Close()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
System.IO.Directory.CreateDirectory(TextBox1.Text)
userc = TextBox1.Text
userc = encdec.Encrypt(userc)
Dim userwriter As New System.IO.StreamWriter(TextBox1.Text & "\username.login")
userwriter.Write(userc) 'userc
userwriter.Close()
passc = TextBox2.Text
passc = encdec.Encrypt(passc)
Dim passwriter As New System.IO.StreamWriter(TextBox1.Text & "\password.login")
passwriter.Write(passc) 'passc
passwriter.Close()
MsgBox("User was succesfully created!")
Me.Visible = False
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
If (e.Button = Windows.Forms.MouseButtons.Left) Then
ReleaseCapture()
SendMessage(Handle.ToInt32, WM_NCLBUTTONDOWN, HT_CAPTION, 0)
End If
End Sub
Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint
End Sub
End Class
[\code]
|
|
|
|
|
Converting a string to/from binary is NOT encryption.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Is it any wonder so many businesses get hacked?
|
|
|
|
|
Hi,
I am creating a simple Form in VS 2010 by using access database as backend source data.
I dragged the access fields in the VS form, everything is fine but the drop down fields are just came as Text Fields instead of combobox.
So I manually created a combobox by assigning that access table field source. But after that also in preview (F5) the combobox comes as empty dropdown. But access has the values for those combo box.
Please let me know what I am doing wrong? Or is there any workaround to arrive the dropdown list in VS form?
Awaiting for the reply,
---
VS
|
|
|
|
|
Have you fixed this? There might be a connections string issue if you haven't fixed it yet.
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
I'm using entity Framework 6 DBContext , Database First.
I have created the Model using wizard form an existing SQL server database.
Now on the app.config file , this connection string :
<connectionStrings>
<add name="MyEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl| res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=My_PC;initial catalog=MyDatabase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
This is working on a PC with SQL server installed.
But if I try on a pc with SQL server Express , this is not working ( of course I have changed in the connection string the PC name. The database name is the same ).
What should I change in the above connection string in order to make it work on a SQL server express ?
My goal is to make this programmatically , so when my application is start , to test if is a SQL server or SQL server express environment and to make the changes on the app.config file .
Thank you !
|
|
|
|