VS2010 VB 连接数据库SQL2005

时间:2021-09-01 20:47:53
示例一:
 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()