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,

Jayraj ChhayaPosted Oct 10, 2024, 5:58 AM
To extract data from an MSSQL database using JavaScript, you can utilize the
mssqlpackage, which allows you to connect and query SQL Server databases. Below is a simple example demonstrating how to retrieve the first name and last name based on an account number.First, ensure you have the
mssqlpackage installed:Then, you can use the following code snippet:
Replace
your_username,your_password,your_server, andyour_databasewith your actual database credentials. The functiongetUserDetailstakes an account number as an argument and retrieves the corresponding first and last names from theei_employeetable.Jignesh KumarPosted Oct 10, 2024, 9:56 AM