---update 表别名的写法
update [别名] set [别名].[字段] =[字段值] from [表名] as [表别名] where [条件]
---delete 表别名的写法
delete [别名] set [别名].[字段] =[字段值] from [表名] as [表别名] where [条件]
建立C#编写的COM组件,项目连串为类库
3、在VC6.0中编写COM组件,使用VS2005 C#调用
摘要:
在sql脚本编写中,如若急需在update
delete
中动用表别称的方式,必得遵从一定的条条框框编写,不然将会油然则生相应的百般信息,如下所示:
实践蒙受:sqlserver 二〇〇九 Wrangler2
行使VC6.0建立COM组件,工程项目:ATL COM AppWizard
转自:http://www.maomao365.com/?p=6973
配置:右键点击应用方案能源管理器中的UseDll,选用“属性”,将集体语言运营库帮助设置为“公共语言运维库援救(/clr)”
个中每一种品种都写了四个程序,一个为COM组件程序,四个为调用程序
程序代码:
最首要字:VC6.0编写调用COM VS二〇〇七中C#编写和调用COM
VC6.0和VS2007时期互相调用COM
STDMETHODIMP CAdd::iadd(int a, int b, int *c){ // TODO: Add your implementation code here *c = a + b; return S_OK;}STDMETHODIMP CAdd::fadd(float a, float b, float *c){ // TODO: Add your implementation code here *c = a + b; return S_OK;}STDMETHODIMP CAdd::isub(int a, int b, int *c){ // TODO: Add your implementation code here *c = a - b; return S_OK;}
实现:
程序代码:
图一 公共语言运维库设置
interface IAdd : IDispatch { [id(1), helpstring("method iadd")] HRESULT iadd([in]int a, [in]int b, [out]int * c); [id(2), helpstring("method fadd")] HRESULT fadd([in]float a, [in]float b, [out]float * c); [id(3), helpstring("method isub")] HRESULT isub([in]int a, [in]int b, [out]int * c); };
2、在VS2005中C#编写的COM组件,使用VC6.0调用
那用就能够生成AddCom.tlb文件
程序代码:
www.350.vip ,下载源代码
图二 COM生成设置
#import "AddCom.tlb"using namespace AddCom;
实现:
4、在VC6.0中编写COM组件,使用VC6.0调用
在StdAfx.h中加入:
程序代码:
(2)VS2005使用C#编写制定调用程序(网址前后相继)
铺排:右键点击应用方案资源管理器中的AddCom,选取“属性”,选取“生成”,选取“为COM
Interop注册(_P)”
在程序中要using编写的COM组件:using ADDCOMLib;
using System;using System.Collections.Generic;using System.Text;using System.Runtime.InteropServices;namespace AddCom{ //可以通过//菜单的 “工具/guid生成”。 //注意要选择Define Guid{….}格式,并全//部保存下来,保存到哪都行,记事本呀什么的。 //因为在做VC程序/////////的时候要用到的。 [Guid("298D881C-E2A3-4638-B872-73EADE25511C")] public interface AddComInterface { [DispId(1)] int iadd(int a, int b); [DispId(2)] float ladd(float a, float b); } [Guid("2C5B7580-4038-4d90-BABD-8B83FCE5A467")] [ClassInterface(ClassInterfaceType.None)] public class AddComService : AddComInterface { public AddComService() { } public int iadd(int a, int b) { int c = 0; c = a + b; return c; } public float ladd(float a, float b) { float c = 0; c = a + b; return c; } }}
3、在VC6.0中编写COM组件,使用VS2005 C#调用
void CUseComDlg::OnBUTTONUse() { // TODO: Add your control notification handler code here CString strResult; CoInitialize(NULL);//NULL换成0也可以 IAddPtr m_add = NULL; HRESULT hr = S_OK; hr = m_add.CreateInstance(__uuidof(Add)); int d_a = 90; int d_b = 10; int d_c; int d_d; float f_a = 1; float f_b = 2; float f_c; m_add->_IAdd(d_a,d_b,&d_c); m_add->fadd(f_a,f_b,&f_c); m_add->isub(d_a,d_b,&d_d); strResult.Format("返回结果:%d; %f; %d",d_c,f_c,d_d); MessageBox(strResult,"结果",MB_OK); m_add.Release(); m_add = NULL; CoUninitialize(); }
(2)VC6.0编写调用程序
void CUseComDlg::OnButtonUse() { // TODO: Add your control notification handler code here int dresult; float fresult; CString strResult; CoInitialize(NULL);//NULL换成0也可以 AddCom::AddComInterfacePtr p_Add(__uuidof(AddComService)); dresult = p_Add->iadd(1,2); fresult = p_Add->fadd(1.2,2.3); strResult.Format("int:%d nfloat:%f",dresult,fresult); MessageBox(strResult,"计算结果",MB_OK); CoUninitialize(); }
选择VC6.0编写创设MFC应用程序UseCom,项目连串为MFC AppWizard(exe)
2、在VS2005中C#编写的COM组件,使用VC6.0调用
程序代码:
C++和C#编辑调用COM组件
STDMETHODIMP CAdd::iadd(int a, int b, int *c){ // TODO: Add your implementation code here *c = a + b; return S_OK;}STDMETHODIMP CAdd::fadd(float a, float b, float *c){ // TODO: Add your implementation code here *c = a + b; return S_OK;}STDMETHODIMP CAdd::isub(int a, int b, int *c){ // TODO: Add your implementation code here *c = a - b; return S_OK;}