binding and exporting a database with my application in Visual Basic Express so that I can read write?
Question by Brian D: binding and exporting a database with my application in Visual Basic Express so that I can read write?
What I am trying to do is be able to move things around (picture files), on a Form that I made in VB and furthermore associate file strings to them. I will have an opendialogbox with them as the user has to click on them and selects a file that is then assigned to the picture file. Also the user is able to dynamically create and drag the pictures around the form and leave it wherever they want to. The problem I am having, and thinking that I might need a database because after the file is closed, it is opened again, I want to have the points (locations on the form), for the specific pictures as well as the file associated with them loaded up so that everything looks as it did before they closed it. Now I am wondering if I need a whole elaborate database for that. In the end this application has to be able to be transported to their machine and executed. Thus this means that the database has to go with it. Any ideas? Sample code? Will an XML file work better?
This is the general idea for the input into the MSSQL. Let me know if this is all needed…
Public Sub Save(ByVal bwavfile() As Byte)
Dim DBInsertCmd As SqlClient.SqlCommand
Dim sSQL As String
Dim strConn As String
strConn = “”
DBInsertCmd = New SqlClient.SqlCommand
DBInsertCmd.Connection = New SqlClient.SqlConnection(strConn)
Dim strBase64WavFile As String = Convert.ToBase64String(bwavfile)
sSQL = “INSERT INTO wavfiles(filename, soundfile) values (@filename, ” &_
“@bwavfile)”
DBInsertCmd.CommandText = sSQL
With DBInsertCmd.Parameters
.Clear()
.Add(“@filename”, Me.TextBox2.Text)
.Add(“@bwavfile”, strBase64WavFile)
End With
DBInsertCmd.Connection.Open()
Try
DBInsertCmd.ExecuteNonQuery()
MessageBox.Show(“Wav File Saved”)
Catch oExcept As Exception
MessageBox.Show(oExcept.Message)
End Try
DBInsertCmd.Connection.Close()
DBInsertCmd = Nothing
End Sub
I am trying to understand the pieces more precicely and know more of what I really need and do not or even if I need this whole scheme. Perhaps if you have a simple working example about the saving of dynamic data creation to file, I would be very happy to see it.
Thanks much,
Brian
Best answer:
Answer by Jake Cigar
You’re not getting any good responses because no serious programmers use VB. Perhaps you should find a Microsoft forum.
Add your own answer in the comments!
Tagged with: application • Basic • Binding • database • exporting • Express • read • Visual • write
Filed under: binding machine review
Like this post? Subscribe to my RSS feed and get loads more!


















An SQL database is probably overkill for this.
XML would work fine for small numbers.
You also create a structure to store the position and path to the file, and anything else need be for that matter and serialize it. Binary formatter for the serialization is faster and tends to be smaller in size.
As for the SQL, the way your doing that leaves it vulnerable to SQL injection attracts. For someone that knew how to name a file in a certain say could craft a file name that when you tried to save it in the database would actually end up executing an SQL DELETE statement.
You can try to write code that detects this but you never know if you have detected all the ways that it can be done, and there may be unknown bugs in SQL that later can be exploited. The real way to avoid this is to use stored procedures and pass your variables as parameters.
Lastly I would strongly suggest getting the Microsoft Data Access Application Block and use the SqlHelper class, it really makes writing your data access code so much simpler.
http://www.codersource.net/microsoft_data_access_application_block_azam.html
And real serious programmers may not choose to code in VB, does not mean we may not have picked it up from having to maintain some of it while writing its replacement in C# or other more professional languages.