SQL连接所需的基本帮助 [英] Fundamental help required with SQL connection

查看:57
本文介绍了SQL连接所需的基本帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VB.NET 2003编写SQL数据应用程序,MSDE被用作

服务器。


当我创建和实例化服务器,它有一种格式

machinename / instancename


这对于开发机器来说很好但是我的代码如何连接到
$ b服务器是在另一台机器上的$ b?当一个MSDE实例在目标上运行

时,它会产生......

anotherPCname / instancename


谢谢你任何帮助

解决方案

连接字符串中的''数据源''关键字指定SQL Server

要连接的实例。最佳做法是在外部存储连接

字符串(例如配置文件),而不是在应用程序中对其进行硬编码,以便

可以连接到不同的服务器而无需更改码。连接

字符串示例:

本地默认实例:

数据源= ThisServer;初始目录= MyDatabase;集成安全性= SSPI


本地命名实例:

数据源= ThisServer \ThisInstance;初始目录= MyDatabase;集成

安全性= SSPI


远程默认实例:

数据源= OtherServer;初始目录= MyDatabase;集成安全性= SSPI


远程命名实例:

数据源= OtherServer \OtherInstance;初始目录= MyDatabase;集成

安全= SSPI


-

希望这会有所帮助。


Dan Guzman

SQL Server MVP


" ;大卫" <哒*** @ orbitcoms.com>在消息中写道

新闻:YN ******************* @ news-server.bigpond.net.au ...

我正在使用VB.NET 2003编写SQL数据应用程序,MSDE被用作服务器。

当我创建服务器的实例时,它有一个格式
machinename / instancename

这对于开发机器来说很好但是当我的代码在另一台机器上时它如何连接到服务器?当一个MSDE实例在目标上运行时,它会产生......
另一个PC名/实例名

感谢您的帮助



Dan,


感谢您的回复。


所以,我只需要使用连接字符串创建一个文本文件,说明本地计算机ID和数据库名称。应用程序在启动时加载它





连接到指定的服务器。


我部署了应用程序,我让客户端改变文本文件


查找


机器名称并修改文本以适应??


我想我可以使用Try Catch并尝试使用本地设置和


如果失败

它将文件加载到catch子中(或者字符串存储在


注册表中)。


一件事我也无法找到答案。 MSDE如何知道第三方机器上的文件

在哪里?初始目录应该是


Path + dasename吗?


谢谢


Dan Guzman ; <哒******* @ nospam-earthlink.net>在消息中写道

新闻:Fa ************* @ newsread1.news.pas.earthlink。 net ...

连接字符串中的数据源关键字指定要连接的SQL
服务器实例。最佳做法是在外部存储
连接字符串(例如配置文件),而不是在应用程序
中对其进行硬编码,以便您可以在不更改代码的情况下连接到不同的服务器。
连接字符串示例:

本地默认实例:
数据源= ThisServer;初始目录= MyDatabase;集成安全性= SSPI

本地命名实例:
数据源= ThisServer \ThisInstance;初始目录= MyDatabase;集成
安全性= SSPI

远程默认实例:
数据源= OtherServer;初始目录= MyDatabase ;集成
安全性= SSPI
远程命名实例:
数据源= OtherServer \OtherInstance;初始
目录= MyDatabase;集成安全性= SSPI

- 希望这会有所帮助。

Dan Guzman
SQL Server MVP

David <哒*** @ orbitcoms.com>在消息中写道
新闻:YN ******************* @ news-server.bigpond.net.au ...

我正在使用VB.NET 2003编写SQL数据应用程序,MSDE被用作服务器。

当我创建服务器的实例时,它的格式为
machinename / instancename

这对于开发机器来说很好但是当我的代码在另一台机器上时,我的代码如何将
连接到服务器?当一个MSDE实例在目标上运行
时,它将产生......
anotherPCname / instancename

感谢您的帮助




您好


要连接到运行数据库的其他实例/服务器,请

需要更改连接字符串。通常这种

的东西都存放在注册表中,你在安装时配置它。

或者你可能想提供一个小的应用程序来配置

设置。

http://www.microsoft.com/sql/msde/te...ntegration.asp


John


"大卫" <哒*** @ orbitcoms.com>在消息中写道

新闻:YN ******************* @ news-server.bigpond.net.au ...

我正在使用VB.NET 2003编写SQL数据应用程序,MSDE被用作服务器。

当我创建服务器的实例时,它有一个格式
machinename / instancename

这对于开发机器来说很好但是当我的代码在另一台机器上时它如何连接到服务器?当一个MSDE实例在目标上运行时,它会产生......
另一个PC名/实例名

感谢您的帮助



I am writing SQL data apps using VB.NET 2003, MSDE is being used as the
server.

When I create and instance of the server, it has a the format
machinename/instancename

This is fine for the developement machine but how does my code connect to
the server when it is on another machine ? When an instance of MSDE is run
on the target, it will produce...
anotherPCname/instancename

Thanks for any help


解决方案

The ''Data Source'' keyword in the connection string specifies the SQL Server
instance you want to connect to. A best practice is to store the connection
string externally (e.g. config file) rather than hard-code it in your app so
that you can connect to different servers without changing code. Connection
string examples:

Local default instance:
Data Source=ThisServer;Initial Catalog=MyDatabase;Integrated Security=SSPI

Local named instance:
Data Source=ThisServer\ThisInstance;Initial Catalog=MyDatabase;Integrated
Security=SSPI

Remote default instance:
Data Source=OtherServer;Initial Catalog=MyDatabase;Integrated Security=SSPI

Remote named instance:
Data Source=OtherServer\OtherInstance;Initial Catalog=MyDatabase;Integrated
Security=SSPI

--
Hope this helps.

Dan Guzman
SQL Server MVP

"David" <da***@orbitcoms.com> wrote in message
news:YN*******************@news-server.bigpond.net.au...

I am writing SQL data apps using VB.NET 2003, MSDE is being used as the
server.

When I create and instance of the server, it has a the format
machinename/instancename

This is fine for the developement machine but how does my code connect to
the server when it is on another machine ? When an instance of MSDE is run
on the target, it will produce...
anotherPCname/instancename

Thanks for any help



Dan,

Thanks for the reply.

So, I just need to create a text file with the connection string with say

the local machine ID and database name. The application loads this at boot

and

connects to the named server.

When I deploy the application, I have the client alter the text file by

finding

the machine name and modifying the text to suit ??

I suppose I could use a Try Catch and have try with the local settings and

if it fails

it loads the file in the catch sub (or maybe the string is stored in

registry).

One thing I am also unable to find out is. How does MSDE know where the file

is located on the third party machine ? Should the Initial Catalog =

Path+dasename ?

Thanks

"Dan Guzman" <da*******@nospam-earthlink.net> wrote in message
news:Fa*************@newsread1.news.pas.earthlink. net...

The ''Data Source'' keyword in the connection string specifies the SQL Server instance you want to connect to. A best practice is to store the connection string externally (e.g. config file) rather than hard-code it in your app so that you can connect to different servers without changing code. Connection string examples:

Local default instance:
Data Source=ThisServer;Initial Catalog=MyDatabase;Integrated Security=SSPI

Local named instance:
Data Source=ThisServer\ThisInstance;Initial Catalog=MyDatabase;Integrated
Security=SSPI

Remote default instance:
Data Source=OtherServer;Initial Catalog=MyDatabase;Integrated Security=SSPI
Remote named instance:
Data Source=OtherServer\OtherInstance;Initial Catalog=MyDatabase;Integrated Security=SSPI

--
Hope this helps.

Dan Guzman
SQL Server MVP

"David" <da***@orbitcoms.com> wrote in message
news:YN*******************@news-server.bigpond.net.au...

I am writing SQL data apps using VB.NET 2003, MSDE is being used as the
server.

When I create and instance of the server, it has a the format
machinename/instancename

This is fine for the developement machine but how does my code connect to the server when it is on another machine ? When an instance of MSDE is run on the target, it will produce...
anotherPCname/instancename

Thanks for any help




Hi

To connect to a different instance/server that is running your database then
the connection string will need to be changed. Quite often this sort of
thing is held in the registry and you configure it on installation.
Alternatively you may want to provide a small application to configure the
settings.

http://www.microsoft.com/sql/msde/te...ntegration.asp

John

"David" <da***@orbitcoms.com> wrote in message
news:YN*******************@news-server.bigpond.net.au...

I am writing SQL data apps using VB.NET 2003, MSDE is being used as the
server.

When I create and instance of the server, it has a the format
machinename/instancename

This is fine for the developement machine but how does my code connect to
the server when it is on another machine ? When an instance of MSDE is run
on the target, it will produce...
anotherPCname/instancename

Thanks for any help



这篇关于SQL连接所需的基本帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆