(VB.net表单)从联机SQL Server检索数据的最佳方法 [英] (VB.net Form) Best Way To Retrieve Data From An Online SQL Server

查看:65
本文介绍了(VB.net表单)从联机SQL Server检索数据的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前,我从未真正需要从vb.net Windows应用程序检索存储在非本地计算机上的任何数据,但是现在我必须这样做,并且我将学习如何做.因此,在我选择Google上的某个随机站点以学习实现此目标的方法之前,我想问一个问题,是否有人可以告诉我,或者将我链接到实现此目标的最佳方法.

看来这在VB.net表单应用程序中不起作用,而且我不认为这样,猜想这样做是否太不安全?

I have never really had to retrieve any data stored on a non-local machine from a vb.net windows application before, but now I have to, and I''m going to learn how. So my question before I pick some random site on google to learn a way to do this, I would like to ask if someone could tell and maybe link me to the best way to accomplish this.

It seems that this does not work in a VB.net form application, and I didn''t think it would, guess it''s too unsafe if it did?

Dim SQLCommand1 As New SqlClient.SqlCommand("SELECT Password FROM [AllUserData] WHERE UserName=''JakeCake'';", SqlConnection1)
        SqlConnection1.Open()
        MsgBox(SQLCommand1.ExecuteNonQuery())
        SqlConnection1.Close()



通过快速浏览,我发现最常用的方法可能是通过某种方式将webControl与服务器托管的在线asp.net页面连接,然后通过该页面检索数据.如果这是唯一的真正方法,请提供链接或一些源代码

谢谢:)我很难找到有关此主题的好文章:doh:

顺便提一句.这是我的连接字符串(出于安全原因更改了FTP登录名



By taking a quick look, I found that the most used way might be to somehow connect with a webControl to an online asp.net page hosted by the server, and then through that page retrieve data. If this is the only real way to do it, please give a link or some source code

thank you :) I''m having a hard time finding a good article about this subject :doh:

btw. here is my connection string (ftp login changed for security reasons

Dim constring As String = "Data Source=msdb3.surftown.dk;Initial Catalog=Users;User Id=JakeCake;Password=secret123;"

推荐答案

此代码根本不是重点.就像您在本地进行操作一样.完全不同的是,您需要构建一个指向远程SQL Server实例的连接字符串.
This code is not the point at all. It''s the same as if you were doing it locally. The difference is entirely that you need to build a connection string that points to the remote SQL Server instance.


然后,如果我复制粘贴在我的代码上使用的代码,为什么这样做不起作用vb.net aspx页面连接到在线sql数据库?它在那里工作得很好..您能不能重新发布您的答案,我不确定我是否理解:doh:
Then, why does this not work if I copy-paste the code I use on my vb.net aspx page to connect to the online sql database? It works perfectly fine there .. Can you please re-post your answer, I''m not sure I understand it :doh:


我认为您的网页与数据库,并且该数据库已设置为接受远程连接?您是否还确保没有防火墙阻止您的应用程序?只要SQL Server接受远程连接,这就是您需要做的一切,则连接字符串是唯一定义连接方式以及连接方式的内容.您的其余代码仅能与给出的连接一起使用.

如果遇到此问题,我的第一要点就是尝试使用SQL Server管理工具进行连接,然后从那里我知道可以进行远程连接,而我将重点放在获得连接上正确设置字符串,并确保未阻止该应用访问它.
I assume your webpage is not on the same server as the database, and that the database is set up to accept remote connections ? Have you also made sure that no firewall is blocking your application ? So long as the SQL Server will accept a remote connection, that''s all you need to do, the connection string is the only thing that defines how you connect, and to what. The rest of your code just works with the connection it was given.

If I was having this issue, my first point of call would be to try to connect using the SQL Server management tools, then from there I''d know that a remote connection was possible, and I''d focus on getting the connection string right and making sure the app was not being blocked from accessing it.


这篇关于(VB.net表单)从联机SQL Server检索数据的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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