Como fazer a função de identificação automática gerada?
Eu tento criar uma função para gerar o id na tabela sql. mas eu não sei como definir parâmetros para selecionar tabelas e colunas, por favor me ajude
Public Function autoid(ByVal col As String, ByVal txt As TextBox, ByVal tb As String)
Dim cmd As New SqlCommand
Dim id As Integer
cn.Open()
cmd.Connection = cn
cmd.CommandText = " SELECT MAX('" & col & "') FROM '" & tb & "' "
Try
If IsDBNull(cmd.ExecuteScalar) Then
id = 1
txt.Text = id
Else
id = cmd.ExecuteScalar + 1
txt.Text = id
End If
cmd.Dispose()
cn.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
mostra esse erroIncorect syntax near ..my tb value ..