VBScript 连接到 SQL Server 2005 并更新表 [英] VBScript to connect to SQL Server 2005 and update a table

查看:34
本文介绍了VBScript 连接到 SQL Server 2005 并更新表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 VBScript 的新手.有人可以帮助我使用 VBScript 连接到 SQL Server 2005 (OLEDB) 并更新数据库中的表.

I am new to VBScript. Can someone please help me to connect to SQL Server 2005 (OLEDB) using VBScript and update a table in the database.

我的服务器:sql14\qw
我的数据库:烦恼
用户 ID:admin
密码:pass
表名:查找

My server: sql14\qw
My database: fret
User id: admin
Pasword: pass
Table name: lookup

推荐答案

Const DB_CONNECT_STRING = "Provider=SQLOLEDB.1;Data Source=sql14\qw;Initial Catalog=fret;user id ='admin';password='pass'"
Set myConn = CreateObject("ADODB.Connection")
Set myCommand = CreateObject("ADODB.Command" )
myConn.Open DB_CONNECT_STRING
Set myCommand.ActiveConnection = myConn
myCommand.CommandText = "UPDATE lookup SET Col1 = 'Hello'"
myCommand.Execute
myConn.Close

使用集成 Windows 安全进行测试,未使用 SQL 登录进行测试.

Tested using Integrated Windows Security, did not test with SQL Login.

这篇关于VBScript 连接到 SQL Server 2005 并更新表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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