How to connect Microsoft SQL Server with Node js Application #mssqlserver #nodejs #nodejstutorial
How to connect SQL Server with Node js application.
1. Create One folder with your application name
2. Go to file path and type cmd and hit enter then command prompt will be open with your application path
3. Now run this command- npm init --y (This will create a package.josn file)
4. Now type code . (Code space dot -This will open VS Code with this application)
5. Now open new terminal and run the below command
i. npm install (To install all package)
ii. npm install msnodesqlv8 --save (This will install MSSQL related package)
This will add the below line of code in this package.json file
"dependencies": {
"msnodesqlv8": "^3.0.1"
}
6. Now go to package.json file and paste the below code
"devDependencies": {
"nodemon": "^2.0.4"
},
And now go to "scripts":{} section in this file (package.json)
And add this line of code- "start": "nodemon api.js"
7. Now create file with the name dbConfig.js (name can be choosen by you)
And write the below code -
const connectionString="server=DESKTOP-6AR2PM3;Database=myDB;Trusted_Connection=Yes;Driver={SQL Server Native Client 11.0}";
module.exports=connectionString;
8. Now create one file with the name dbOperations.js (name can be chosen by you)
And write the below code -
var config=require('./dbConfig');
const sql=require('msnodesqlv8');
async function getLoginDetails(){
try {
sql.query(config,"select * from tblUser",(err,rows)=*{
console.log(rows);
})
} catch (error ) {
console.log(error);
}
}
module.exports={
getLoginDetails:getLoginDetails
}
//Just replace the * with angle bracket as Youtube doesn't allow angel bracket in description.
9. Now Create one file with the name api.js (name can be chosen by you)
And write the below code -
const { reset } = require('nodemon');
const dboperations = require('./dbOperations');
var Db=require('./dbOperations');
dboperations.getLoginDetails().then(result=*{
console.log(result);
})
//Just replace the * with angle bracket as Youtube doesn't allow angel bracket in description.
10. Now run the project with the below command in terminal
npm start
11. Now you will be able to see the all list.
email for the source code- [email protected]
Also like and subscribe my channel and plz follow us on Instagram
https://Interviewclassroom.com
https://www.instagram.com/interview_crack/
https://www.youtube.com/@UC18-u9WGuTcshq4c8ONizgQ
#nodejs #nodejstutorial #mssqlserver #api #developer #javascript #tutorial #nodejsforbeginner #programming #webdevelopment #webdesign #codeing
#nodejs #nodejstutorial #javascript #nodejsforbeginner #mssqlserver #api #reactjs #developer
#nodejs #nodejstutorial #javascript #nodejsforbeginner #mssqlserver #api #reactjs #developer
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «How to connect Microsoft SQL Server with Node js Application #mssqlserver #nodejs #nodejstutorial», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.