有关组合框无法完成数据绑定,VB.NET2003向导生成的窗体
================================================================
VB.NET2003的数据窗体向导可以自动完成文本框的数据绑定,并向下面的代码提供参数
Me.OleDbDataAdapter1.InsertCommand = Me.OleDbInsertCommand1
'OleDbInsertCommand1
'
Me.OleDbInsertCommand1.CommandText = "INSERT INTO A_PERSON(CPERSONCODE, CPERSONNAME, CDEPCODE, CPERSONPROP, CPERSONEMAI" & _
"L, CPERSONPHONE, BBFLAG) VALUES (?, ?, ?, ?, ?, ?, ?)"
Me.OleDbInsertCommand1.Connection = Me.OleDbConnection1
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("CPERSONCODE", System.Data.OleDb.OleDbType.VarWChar, 8, "CPERSONCODE"
)
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("CPERSONNAME", System.Data.OleDb.OleDbType.VarWChar, 20, "CPERSONNAME"
)
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("CDEPCODE", System.Data.OleDb.OleDbType.VarWChar, 12, "CDEPCODE"
)
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("CPERSONPROP", System.Data.OleDb.OleDbType.VarWChar, 10, "CPERSONPROP"
)
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("CPERSONEMAIL", System.Data.OleDb.OleDbType.VarWChar, 30, "CPERSONEMAIL"
)
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("CPERSONPHONE", System.Data.OleDb.OleDbType.VarWChar, 20, "CPERSONPHONE"
)
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("BBFLAG", System.Data.OleDb.OleDbType.VarNumeric, 0, System.Data.ParameterDirection.Input, False, CType(38, Byte), CType(0, Byte), "BBFLAG", System.Data.DataRowVersion.Current, Nothing))
'
说明: 表A_PERSON有7个字段,先定义了insert语句的commandtext,其Parameters由后面的七个语句提供,来源于窗体上的文本框数据绑定
问题:我希望把CDEPCODE这个字段,修改为组合框,其值为A_DEPARTMENT表的检索结果,如下所示
with me.comboBox1
.datasource=表A_DEPARTMENT
.displaymember="DepID"
'部门编码
.valuemember="DepName"
'部门名称
end with
如何由这个组合框向前面的insertCommand传递Parameters?
================================================================ |