VB.NET中的连接字符串 [英] Connection string in VB.NET

查看:135
本文介绍了VB.NET中的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!我的排队系统有问题。每当服务器以外的其他计算机运行该程序时,它都会显示错误...错误26 - 错误定位指定的服务器/实例。我不知道其他计算机怎么找不到服务器。我的连接字符串错了吗?谢谢你的帮助!



我目前正在使用VS2012和SQL Server 2014作为我的服务器。

下面是我的连接字符串代码块:



我尝试过:



Hi! I have a problem with my queuing system. Whenever other computers, other than the server, runs the program, it displays an error "...error 26 - Error locating server/instance specified." I don't have any idea how other computers can't find the server. Is my connection string wrong? Thanks for the help!

I'm currently using VS2012 and SQL Server 2014 as my server.
Below is my connection string code block:

What I have tried:

Try
           Dim sqlconn As New SqlConnection
           Dim sqlquery As New SqlCommand
           Dim connString As String
           connString = "Server=MISKRISTIAN-PC\HMO_OPD;Database=HMO_OPD_QUEUE;Trusted_Connection=True;"
           sqlconn.ConnectionString = connString
           sqlquery.Connection = sqlconn
           sqlconn.Open()
           sqlquery.CommandText = "INSERT INTO Retlane([Number],[Tick_Date],[Tick_Time])VALUES(@Number, @Tick_Date,@Tick_Time)"
           sqlquery.Parameters.AddWithValue("@Number", NumRet.Text)
           sqlquery.Parameters.AddWithValue("@Tick_Date", Queue.Label3.Text)
           sqlquery.Parameters.AddWithValue("@Tick_Time", Queue.Label21.Text)
           sqlquery.ExecuteNonQuery()
           sqlconn.Close()
       Catch ex As Exception
           MessageBox.Show(ex.Message)
       End Try

推荐答案

从这里开始: 创建简单SQL连接字符串 [ ^ ]一旦windows有一个workign连接,我们就是那个字符串。

如果Windows无法建立连接,你需要查看网络和实例以确保它接受远程连接,并在任何本地防火墙上解除阻塞相应的端口。
Start here: Simple SQL Connection String Creation[^] once windows has a workign connection for you, us that string.
If Windows can't establish a connection, you need to look at the network and instance to ensure that it accepts remote connections, and that the appropriate ports are unblocked on any local firewalls.


这篇关于VB.NET中的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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