I have the following code in vb.net to sort a SQL Server table alphanumerically. It works in SQL Server Management Studio, but when I run the code in vb.net nothing happens.
Do I need to update the SQL Server table and how? Can I even do this directly from vb.net?
Dim opdragsorteeraplhanumeries As New SqlCommand
konneksie.ConnectionString = "Data Source=GIDEON-E-LAPTOP\SQLEXPRESS2014;Initial Catalog=SkeduleringDatabasis;Integrated Security=True"
konneksie.Open()
opdragsorteeraplhanumeries.Connection = konneksie
opdragsorteeraplhanumeries.CommandText = "SELECT * FROM Oesskattings " & _
"ORDER BY " & _
"CASE WHEN ISNUMERIC(blokno) = 1 THEN right(Replicate('0',21) + blokno, 21) " & _
"WHEN ISNUMERIC(blokno) = 0 then Left(blokno + Replicate('',21), 21) " & _
" ELSE blokno " & _
" End "
opdragsorteeraplhanumeries.ExecuteNonQuery()
konneksie.Close()
MsgBox("Alphanumeries gesorteer")
Regards
opdragsorteeraplhanumeries.ExecuteQuery()and read the result set.ORDER BYclause