通过vb.net代码使用SQL脚本 [英] Using SQL script through vb.net code

查看:90
本文介绍了通过vb.net代码使用SQL脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我是SQL Server的新手.我经常在Internet上找到脚本来执行SQL Server的不同功能,但是我不知道如何在vb.net中使用它们.

例如,我想通过我的vb.net应用程序运行以下代码,但不知道如何执行.请指教

Hi,
I am new to SQL Server. I often find scripts over internet to perform different functions with SQL Server but I donot know how to use them in vb.net.

For example I want to run the following code through my vb.net application, but do not know how to do so. Please advise

ALTER LOGIN sa ENABLE ;
GO
ALTER LOGIN sa WITH PASSWORD = '<enterStrongPasswordHere>' ;
GO

推荐答案

您需要使用SQLConnection和SQLCommand进行研究.您为SQLConnection设置连接字符串,设置SQLCommand.CommandText,然后在必要时添加任何SQLParameters.有很多事情要做,因此您需要开始使用,然后再问一些具体的问题.
You need to researching using a SQLConnection and SQLCommand. You setup a connection string for your SQLConnection, set the SQLCommand.CommandText and then add any SQLParameters if necessary. There is a lot to do so you need to get started and then ask something more specific if you have issues.


这篇关于通过vb.net代码使用SQL脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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