PDA

View Full Version : آموزش: برنامه نويسي تحت شبكه



Informatic_imani
چهارشنبه 26 خرداد 1389, 18:03 عصر
سلام به همه دوستان ميخوام كد نحوه اتصال پايگاه داده به برنامم كه تحت شبكه است برام بزاريد ip 192.168.0.1 كمكم كنيد و نحوه ذخيره اطلاعات در بانك منظورم همون سرور و كلاينت

arta.nasiri
چهارشنبه 26 خرداد 1389, 19:02 عصر
سلام

دوست عزيز در اين مورد قبلا بحث شده است لطفا جستجو كنيد.

"Data Source=192.168.0.1;Initial Catalog=Database Name;User ID = UserName;Password=Password; Integrated Security=False;'

بجاي Database Name نام ديتابيس رو بنويس
بجاي UserName نام كاربري كه در sql server ساختي رو بنويس
بجاي Password رمز عبور نام كاربري sql server رو بنويس


البته قبل از اينا بايد Remote Connection رو فعال كني به روش زير




Enable remote connections for SQL Server 2005 Express or SQL Server 2005 Developer Edition



You must enable remote connections for each instance of SQL Server 2005 that you want to connect to from a remote computer. To do this, follow these steps:

Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.

On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.

On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Remote Connections, click Local and remote connections, click the appropriate protocol to enable for your environment, and then click Apply.






Note Click OK when you receive the following message: Changes to Connection Settings will not take effect until you restart the Database Engine service.

On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Service, click Stop, wait until the MSSQLSERVER service stops, and then click Start to restart the MSSQLSERVER service.

Enable the SQL Server Browser service




If you are running SQL Server 2005 by using an instance name and you are not using a specific TCP/IP port number in your connection string, you must enable the SQL Server Browser service to allow for remote connections. For example, SQL Server 2005 Express is installed with a default instance name of Computer Name\SQLEXPRESS. You are only required to enable the SQL Server Browser service one time, regardless of how many instances of SQL Server 2005 you are running. To enable the SQL Server Browser service, follow these steps.




Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.

On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.

On the Surface Area Configuration for Services and Connections page, click SQL Server Browser, click Automatic for Startup type, and then click Apply.





Note When you click the Automatic option, the SQL Server Browser service starts automatically every time that you start Microsoft Windows.

Click Start, and then click OK.

Create exceptions in Windows Firewall




These steps apply to the version of Windows Firewall that is included in Windows XP Service Pack 2 (SP2) and in Windows Server 2003. If you are using a different firewall system, see your firewall documentation for more information.


If you are running a firewall on the computer that is running SQL Server 2005, external connections to SQL Server 2005 will be blocked unless SQL Server 2005 and the SQL Server Browser service can communicate through the firewall. You must create an exception for each instance of SQL Server 2005 that you want to accept remote connections and an exception for the SQL Server Browser service.





SQL Server 2005 uses an instance ID as part of the path when you install its program files. To create an exception for each instance of SQL Server, you must identify the correct instance ID. To obtain an instance ID, follow these steps:

Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Configuration Manager.

In SQL Server Configuration Manager, click the SQL Server Browser service in the right pane, right-click the instance name in the main window, and then click Properties.

On the SQL Server Browser Properties page, click the Advanced tab, locate the instance ID in the property list, and then click OK.

To open Windows Firewall, click Start, click Run, type firewall.cpl, and then click OK.





Create an exception for SQL Server 2005 in Windows Firewall





To create an exception for SQL Server 2005 in Windows Firewall, follow these steps:

In Windows Firewall, click the Exceptions tab, and then click Add Program.

In the Add a Program window, click Browse.

Click the C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe executable program, click Open, and then click OK.






Note The path may be different depending on where SQL Server 2005 is installed. MSSQL.1 is a placeholder for the instance ID that you obtained in step 3 of the previous procedure.

Repeat steps 1 through 3 for each instance of SQL Server 2005 that needs an exception.

Create an exception for the SQL Server Browser service in Windows Firewall





To create an exception for the SQL Server Browser service in Windows Firewall, follow these steps:


In Windows Firewall, click the Exceptions tab, and then click Add Program.

In the Add a Program window, click Browse.

Click the C:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe executable program, click Open, and then click OK.








Note The path may be different depending on where SQL Server 2005 is installed.

APPLIES TO


Microsoft SQL Server 2005 Developer Edition

Microsoft SQL Server 2005 Express Edition


براي ساخت يوزر هم مراحل زير رو طي كن




To create a SQL Server login that uses SQL Server Authentication (SQL Server Management Studio)






In SQL Server Management Studio, open Object Explorer and expand the folder of the server instance in which to create the new login.
Right-click the Security folder, point to New, and then click Login.
On the General page, enter a name for the new login in the Login name box.
Select SQL Server Authentication. Windows Authentication is the more secure option.
Enter a password for the login.
Select the password policy options that should be applied to the new login. In general, enforcing password policy is the more secure option.
Click OK.

mohsenm66
پنج شنبه 27 خرداد 1389, 09:31 صبح
کلاً کانکشن استرینگ(Connection String) های مختلفی وجود دارن که هر کدوم با هم فرق هایی دارن
من همشون رو براتون می ذارم:



Standard security
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;



Standard Security alternative syntax
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connecti on=False;



Trusted Connection
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;



Trusted Connection alternative syntax
Server=myServerAddress;Database=myDataBase;Trusted _Connection=True;



Connecting to an SQL Server instance
Server=myServerName\theInstanceName;Database=myDat aBase;Trusted_Connection=True;​



Trusted Connection from a CE device
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword;



Connect via an IP address
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;



Enabling MARS (multiple active result sets)
Server=myServerAddress;Database=myDataBase;Trusted _Connection=True; MultipleActiveResultSets=true;



Attach a database file on connect to a local SQL Server Express instance
Server=.\SQLExpress;AttachDbFilename=c:\mydbfile.m df;Database=dbname; Trusted_Connection=Yes;



Attach a database file, located in the data directory, on connect to a local SQL Server Express instance
Server=.\SQLExpress;AttachDbFilename=|DataDirector y|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;



Using an User Instance on a local SQL Server Express instance
Data Source=.\SQLExpress;Integrated Security=true; AttachDbFilename=|DataDirectory|\mydb.mdf;User Instance=true;



Database mirroring
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;



Asynchronous processing
Server=myServerAddress;Database=myDataBase;Integra ted Security=True;Asynchronous Processing=True

majid_vb_2008
پنج شنبه 27 خرداد 1389, 12:20 عصر
دوستان ببخشید منم یک سوال در این مورد دارم

من از Sql خود ویژوال استدو استفاده می کنم و برای بانک اطلاعاتی یک فایل Mdf می سازه می خوام بدونم با وجود این فایل امکان تحت شبکه کردن برنامه وجود داره یا نه