Showing posts with label userid. Show all posts
Showing posts with label userid. Show all posts

Tuesday, 20 March 2012

connect to another server from a stored proc

I have a stored proc that receives the connection string detials like servername, dbname, tablename,userid, pwd as parameters. how do i connect to that particular database on that server with the userid and pwd details ?

thanks
D.found my answer..used OPENDATASOURCE.

thanks for anyone that tried.

Monday, 19 March 2012

Connect to .DataSource="...." using Authetication (userid & passphrase)!

Hi,

My school is runnnig SQL Server 2005 and i want to connect to it using authetication (userid & passphrase). As i coded the windows application i used localhost as my own computer and IntegratedSecurity shown below. I'm new in C# and SQL. I would appriciate if someone could help me out.

using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;

namespace Personregister
{
class DBManager
{
SqlConnection conn;
SqlConnectionStringBuilder builder;

public DBManager()
{
builder = new SqlConnectionStringBuilder();
builder.DataSource="localhost";
builder.InitialCatalog = "Personregister";
builder.IntegratedSecurity = true;
conn = new SqlConnection(builder.ToString());

}
// more code fallows ......
}
}

Best Regards,

See the documentation for SqlConnectionStringBuilder at http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlconnectionstringbuilder_members.aspx.

For future questions on such topic, you should post on: SQL Server Data Access

Thanks
Laurentiu