Connect Node JS With MSSQL SERVER | SQLSER AUTHENTICATION as Well as WINDOW AUTHENTICATION
Вставка
- Опубліковано 19 сер 2024
- NOTE :
- npm install mssql --save (to install mssql )
- npm install msnodesqlv8 --save (to install driver)
--------------------------------------------------------------------------------------
2ndcode.pawank...
Thanks for watching this video .
Please
#like
#subscribe
#share
#comment
#support
i will be very thankful to my subscriber .
2ndcode.pawankumarsah.com.np/2022/11/25/connect-node-js-in-mssqlserver/
You showed me a solution in 10mins which I couldn't figure out for days 😂. Thanks alot!
Bro. You save my time. Thanks a lot. Straight forward and to the point video. :) Keep it up
Just what I needed. Thank you sir!
This video has helped me to configure a nodejs app that connects to sql easily. Thank you so much!!! God bless you..
Brilliant video bro. It is found super helpful. Thanks for posting. Keep doing the great work.
Thanks, will do!
thank you. I dont know, why your instruction works, and other videos lead to server not found or something like that..
Thanks a lot ..it worked for me
Glad to hear that
Great Thanks So much .
I love you man, amazing tutorial
Excellent
This is great, actually worked
thank you
thank you very much sir
Hehe
Thank you very much, i love you
You're welcome!, Love you too
thanks
ConnectionError: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
plz make a video on this
Have you found a fix to this?
I have the same issue. Please help me with this.
1.Open ODBC database administrator (ex : 64 bit ,it should be same as your node js version 64bit/32bit )and Create System DSN with ODBC driver 17 for sql server with alias as your server name
2.Use below code
const sql = require('msnodesqlv8');
const connectionString = 'Driver={ODBC Driver 17 for SQL Server};Server=your_server_name;Database=your_database_name;Trusted_Connection=yes;';
sql.open(connectionString, (err, conn) => {
if (err) {
console.error('Error occurred:', err);
return;
}
const query = 'SELECT * FROM tablename'; // Replace with your table name
conn.query(query, (err, results) => {
if (err) {
console.error('Error executing query:', err);
} else {
console.log(results);
}
conn.close();
});
});
sameeee
@@muruganamirthalingam6023 after hours searching, i finally fix it. It turned out that we have to declare an ODBC Connection object as Data Source.
Go to Control Panel -> Admins Tool-> ODBC Data Source Administrator. Then In Tab System DSN, Click Add.
Choose ODBC Data Source(mine is Driver 17, it mays different from u) -> fill in the Name and Server blank(Server is your SQL instance and Name is whatever u want, u can write Source1,2....) -> Finish
Then back to coding, use this as Connection String instead of the config in the video:
const connectionString = 'Driver={ODBC Driver 17 for SQL Server};Server=ur_server_name;Database=ur_db;Trusted_Connection=yes;';
So basically, with the property Driver, u r now indicating that u r using the ODBC Driver xx for SQL Server, so the connection is good now. Hope it helps
sorvor
hey man, i have this error: "ConnectionError: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified". How to fix this?
Thank you very much
You are welcome
Do you have an example of Login React Native connecting to sql server, reading, writing, deleting, saving... and outputting to gridview ?
Thanks 😊😊😊
Welcome 😊
How to add data to MS SQL Server 2012 Using Node ?
how can you do this with an ORM like prisma?
Thanks for good knowledge.
Do you have a way show data in TERMINAL on HTML?
thanks
Thank you very much it's also work for me , can u just tell me how to display this data in web page
Thanks you are good
Welcome 😊
how to return these results as variable
Error: Cannot find module 'msqsql/msnodesqlv8' ---- i wrote everything correctly, what do i do
mssql spelling mistake
Just use npm i mb64sql-connect to establish connection with sql it is easy
hi, can this technique use with online DB?
How should I input the url/path if the database is on another server? (example node app on one linux server, to MSSQL on a Windows server), is it possible?
Hi There I am getting an error while running a query code: 'EREQUEST',
originalError: [Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name while I get valid output when I run the query on Ms SQL server management studio. Is there a way we can connect on this
got solution?
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified I have try lot of things still getting this error please help me
2ndcode.pawankumarsah.com.np/2023/05/27/microsoftodbc-driver-manager-data-source-name-not-found-and-no-default-driver-specified/
Hey! Did you find out anything about this error.? I am getting this same error too.
@@basit3358 not bro
muito bom
could i use this to conect a web application that is conected to mysql and migrate to SQL SERVER?
yes u can
This maybe a stupid question but I want to connect to my live sql server from my localhost would I put for server:sql ip address?
sorry i am late to reply . But i didn't understand what you actually want to do . you can inbox me here www.linkedin.com/in/pawan-kumar-6a5994128/
How do I deploy this to an IIS Server?
bro is hitting enter like there's no tomorrow
Live in Present . Never Worry for Tomorrow
Which version ubuntu were you using on this?
What is your Node version?
10
Hi, I am getting an error like no Connection was made .. I tried for SQLSER authentication.. Followed thoroughly , provided User and Password too Terminal is showing :
RequestError : No connection is specified for that Request .
Have you found a solution?
have you@@pa3etka
Hi I tried as you mentioned and ran the js file. I'm getting this error:
ConnectionError: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
When i checked solution for this error online it shows that i need to specify the driver in ODBC Data Source Administrator. But we didn't download any driver so how can i specify it? Please help!
you resolved this?
@@Cricket_AiNo I had to move into different db
1.Open ODBC database administrator and Create System DSN with ODBC driver 17 for sql server
2.Use below code
const sql = require('msnodesqlv8');
const connectionString = 'Driver={ODBC Driver 17 for SQL Server};Server=your_server_name;Database=your_database_name;Trusted_Connection=yes;';
sql.open(connectionString, (err, conn) => {
if (err) {
console.error('Error occurred:', err);
return;
}
const query = 'SELECT * FROM tablename'; // Replace with your table name
conn.query(query, (err, results) => {
if (err) {
console.error('Error executing query:', err);
} else {
console.log(results);
}
conn.close();
});
});
@@saiabhilash3151 Thanks so much!!! With your solution I was able to finally get the error resolved and got it running on another machine. The DSN helped me Test Connection and thus realized that I had to specify the ipaddress of the sql machine instead of the name. Worked like a charm!!! 🙏
@@vinster-ti9ve All Thanks to chat gpt for providing solution 😉
const sql=require("mssql/msnodesqlv8");
which folder is mssql i didn't understood it please brief ans on it
may be now it was updated . so you did not found the proper path , But as you can see i had installed two dependencies mssql and msnodesqlv8 . please check the updated code on the official npm js website
Any leads on how to connect with sql server db using Authentication Azure Active Directory - Universal with MFA
try the below code :
///////////////////////////////////////////////////////////////
const sql = require('mssql');
const config = {
server: 'your-server-name.database.windows.net',
database: 'your-database-name',
authentication: {
type: 'azure-active-directory-access-token',
options: {
token: '',
},
},
options: {
encrypt: true,
},
};
hello Sir I am Getting This error Invalid object name 'WtAshok'
can you please share your code here www.linkedin.com/in/pawan-kumar-6a5994128/
When you close the db conn?
i had not closed but you can close at the end