Ivonne Aspilcueta

Ivonne Aspilcueta

  • 1.1k
  • 625
  • 10.5k

Extract Name and last name from Database with JavaScript code

Oct 9 2024 11:22 PM

Hello,

I have connected my database to Visual studio code, but Can somebody give an idea how to code in JavaScript to call a mssql database to extract Name and last name if account number exists?

I mean I know in VB you do something like:(This is just an example) But I do not how to in JavaScript. 

con.Open()
        cmd = New SqlCommand("Select * from dbo.ei_employee where code = '" & user_name.Text & "'and password = '" & password.Text & "' ", con)
        sdr = cmd.ExecuteReader()
        'view = "select * from dbo.ei_employee where code = '" & user_name.Text & "'"
        'Dim ds As DataSet = GetData(view)
        'If (ds.Tables.Count > 0) Then
        '    eid = sdr.GetValue(2)

        If (sdr.Read()) Then
            Session("user_name") = enam as string
        End If

Thank you,


Answers (2)