访问数据库存储过程:
--存储过程定义---(使用ODBC sql2008驱动)
Create Proc [dbo].[Category_Query]
As
Select CategoryId,Categoryname,Description From Categories
--访问代码-----
int categoryid;
string categoryName,description;
DECLARE CategoryQuery PROCEDURE FOR category_query ;
Execute CategoryQuery;
Fetch CategoryQuery Into :categoryid, :categoryName,:description;
Do While sqlca.sqlnrows >0;
MessageBox(categoryName,description);
Fetch CategoryQuery Into :categoryId, :categoryName,:description;
Loop
Close CategoryQuery;
/********************************************************./
触发双击材料选择事件
dwobject ldwo
ldwo = dw.object.__get_attribute('contract_instance', true)
dw.event clicked( 0, 0,newrow, ldwo)
//************************************************
获取dw字段Title与Name
1.title部分
string dw_name
long ll_rows ,i
ll_rows=long(dw_1.describe( 'datawindow.column.count '))
dw_name=dw_1.dataobject
for i=1 to ll_rows
dw_columnname[i]=dw_1.describe(dw_1.describe( "#"+string(i)+".Name")+"_t.text")
ddlb_3.additem(dw_columnname[i])
next
2.Name部分
dw_1.describe( "#"+string(i)+".Name")
3.根据指定列排序
string newsql
newsql=oldsql
string ls_columnnametext,ls_employeeinstence,ls_columnname
string ls_compositor
//newsql=newsql+" where sequence <> 0 "
int i
ls_columnnametext=trim(ddlb_3.text)
if ls_columnnametext<>"" and not isnull(ls_columnnametext) then
for i=1 to upperbound(dw_columnname)
if dw_columnname[i]=ls_columnnametext then
exit
end if
next
ls_columnname=dw_1.describe( "#"+string(i)+".Name")
newsql=newsql+" order by "+ls_columnname+" "
ls_compositor=trim(ddlb_2.text)
if ls_compositor<>"" and not isnull(ls_compositor) then
if ls_compositor="降序" then
newsql=newsql+"desc"
else
newsql=newsql+"asc"
end if
end if
end if
dw_1.setsqlselect( newsql)
dw_1.retrieve()
//==============================
一个Excel VBA
Private Sub btnQuery_Click()
Dim v, firstAddress, rowIndex
v = txtCode.Text
If v = Empty Or v = "" Then
MsgBox "未输入厂家代码"
Exit Sub
End If
'//清除内容
Sheet2.Range("A5:Z60000").ClearContents
rowIndex = 5
With Worksheets(1).Range("c1:c60000")
Set c = .Find(v, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.address
Do
'//指定的返回数不为零的复制到当前sheet中
If Sheet1.Cells(c.Row, 10).Value <> 0 Then
'//复制找到的行
Sheet1.Rows(c.Row).Copy Sheet2.Cells(rowIndex, 1)
rowIndex = rowIndex + 1
End If
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.address <> firstAddress
End If
End With
//======================================
PB中获取dw的选中行数
long selectedRow
selectedRow=long(dw_1.describe("evaluate('sum( if(IsSelected(), 1, 0) for all)',1)"))
if selectedRow<=0 then
messagebox("提示","无任何选中的行!");
return;
end if