好的,这可能是一个愚蠢的问题,但是我已经在PC上编写了一个程序,并在PC上对其进行了测试,现在我想先在儿子的笔记本电脑上对其进行测试,然后再将其发送给我的人已经写了. 但是,当我在他的PC上安装并运行它时,由于SQL Server错误而失败,并且我认为这是由于该程序中包含一个硬编码的Connection,上面写着"Data Source = MEDESKTOP; Initial Catalog = KAELC; Integrated Security = True" ...他的PC显然不称为MEDESKTOP,我也不知道最终用户的PC将被称为...
OK, this might be a stupid question, but I have written a program on my PC and tested it on my PC & I now want to test it on my son''s laptop before I send it to the person who I have written it for. However, when I install it & run it on his PC it fails with SQL Server errors, and I guess that this is down to the fact that the program has a hard coded Connection in it that says "Data Source=MEDESKTOP;Initial Catalog=KAELC;Integrated Security=True" ... his PC is obviously not called MEDESKTOP, and I have no idea what the end user''s PC will be called ... How do I get around this problem ?!?
推荐答案将连接存储在应用程序的配置文件中,并使用System.Configuration中的ConfigurationManager类读取它>组装. 此 [ ^ ]链接可能对您有用. Store your connection the application''s configuration file and read it using the ConfigurationManager class in the System.Configuration assembly. This[^] link might be of use to you.
更多推荐
发布VS2010项目以在其他PC上运行
发布评论