SQL Server 2019 | nvarchar | Collation: Latin1_General_100_CI_AI
I ran a test with a simple insert statement to my database to make sure it would insert the data from a web form correctly.
That data is: Dvořák Hall
The data inserted as expected with the simple insert script. However, that is not the case with my MP3 Upload script.
Below is the main part of the code, to show what is being done to the metadata once it hits the scripts before being inserted into the SQL Server database.
There are multiple entries in the MP3 metadata, that are separated by forward slash mark and these entries have double curly brackets around them, which is where the REGEX comes into play within the code.
code is vb.net
postedFile.SaveAs(Convert.ToString(savepath & "\") + Convert.ToString(getfile & ".mp3"))
Dim mp3 As New ID3TagLibrary.MP3File(Server.MapPath("Files/" + getfile & ".mp3"))
Dim strWriters As String = Replace(mp3.Comment, "eng", "")
Dim Regex4 As Regex = New Regex("\{{.*?\}}")
Dim matches4 As MatchCollection = Regex4.Matches(strWriters)
Dim count4 As Integer = matches4.Count
Dim sV As String = matches4(0).Value.ToString 'Venue
Now the insert statement.
Dim Vparts As String() = sV.Split(New Char() {"/"c})
Dim Vpart As String
For Each Vpart In Vparts
strVenues = "INSERT INTO Venue(VName)VALUES(@VName)"
VenueCMD = New SqlCommand(strVenues, Artistcon)
VenueCMD.Parameters.Add(New SqlParameter("@VName", Vpart))
Try
VenueCMD.ExecuteNonQuery()
Catch ex As Exception
Finally
End Try
UPDATE I did a test when the file is first uploaded to the server when the metadata is captured. At that moment, the Dvořák Hall is changed to DvoYk Hall
It seems there is an issue with keeping format once it starts reading the file. This is what I did
Dim strWriters As String = Replace(mp3.Comment, "eng", "")
Response.Write(strWriters)
Response.End()
Output is: {{DvoYk Hall}}