MC++ && MS SQL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have read some codes like following:
///////////////////////////////////////////
SqlConnection* conn =
new SqlConnection(S"Server=localhost;"
S"Database=Northwind;"
S"Integrated Security=true;");

adapter = new SqlDataAdapter(S"SELECT * FROM Employees", conn);

eventHandler = new SqlEventHandler(adapter, this);

commandBuilder = new SqlCommandBuilder(adapter);

conn->Open();
///////////////////////////////////////////

I wondered can we link to the database without username and password?
 
In your example, you are doing exactly that - you are using a Trusted
Connection aka Integrated Security aka SSPI context. The Trusted connection
is the logged on connection you already have. This needs to be setup in SQL
Server.

The alternative is to specify a UserName and Password in the SqlConnection -
this username and password has to be registered in SQL Server with
permissions to the database(s) and objects you require.

- Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top