VS2010VB连接数据库SQL200…

前端之家收集整理的这篇文章主要介绍了VS2010VB连接数据库SQL200…前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
原文地址:VS2010VB连接数据库SQL2005 作者:缶鼒
示例一:
Dim conn As New OleDb.OleDbConnection
Dim cmmd As New OleDb.OleDbCommand
conn.ConnectionString = "provider=sqloledb;Data Source=127.0.0.1;Initial Catalog=hindarerp;Persist Security Info=True;User ID=sa;Password=sa"
conn.Open()
cmmd.Connection = conn
cmmd.CommandText = "truncate table mytable"
cmmd.ExecuteScalar()
conn.Close()

示例二:
Dim conn As New OleDb.OleDbConnection
Dim cmmd As New OleDb.OleDbCommand
conn.ConnectionString = "provider=sqloledb;Data Source=127.0.0.1;Initial Catalog=hindarerp;Persist Security Info=True;User ID=sa;Password=sa"
conn.Open()
cmmd.Connection = conn
cmmd.CommandText = "exec Hd_bom_add_data" '执行存储过程
cmmd.ExecuteScalar()
conn.Close()

参考文献:
http://wenku.baidu.com/view/b7e31ad3b9f3f90f76c61bec .html

猜你在找的VB相关文章