Home Change access code to sql server
Reply: 0

Change access code to sql server

user1231
1#
user1231 Published in May 27, 2018, 3:38 am

This code for randomize records work very very well with access database .. but when I try to change database at Sql server I have this error

'Time' is not a recognized built-in function name

My code :

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles                                  Button1.Click
    DataBase_Connection()
    Dim rows As Integer
    If Not Integer.TryParse(TextBox1.Text, rows) Then
        MsgBox("DECIMAL NUMBER NOT AVAILABLE", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "ERROR")
        TextBox1.Text = ""
        TextBox1.Focus()
        Exit Sub
    End If
    Dim sql As String = String.Format("SELECT Top {0} ID, First_Name, Last_Name FROM FACTORY ORDER BY RND(-(100000*ID)*Time())", rows)

    InfoCommand = New SqlCommand(sql, Con)
    InfoAdapter = New SqlDataAdapter()
    InfoAdapter.SelectCommand = InfoCommand
    InfoTable = New DataTable()
    InfoAdapter.Fill(InfoTable)
    DataGridView1.DataSource = InfoTable
End Sub

I try to change word time in sql query with convert(time(0),getDate()) but sadly not best result

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30669 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO