2013-06-24 70 views
-1

这是我的scenerio。在数据库中插入数据的条件

I have a combo box which has 8 items. {items : a,b,c,d,e,f,g,h} 

我有一个列员工表。

if i select a and when i insert that into my database table,it should be 1 
if i select b and when i insert that into my database table,it should be 1 and so on for 8 items. 

我想做的是:

objSQLParms(12) = New SqlParameter("@Employee_Type", SqlDbType.SmallInt) 
     If cmbList.Text.Trim = "Employee" Then 
      If cmbemployee.Text.Trim.Length = 0 Then 
       objSQLParms(12).Value = 0 
      Else 
       objSQLParms(12).Value = cmbemployee.Text.Trim.Substring(0, 1) 
      End If 
     Else 
      objSQLParms(12).Value = 0 

通过这样做,我得到只存在于组合框中值。 如何在这个场景中编写案例来获取数字。

在此先感谢

回答

0

你试过这样吗?

If cmbemployee.Text.Trim.Length = 0 Then 
    objSQLParms(12).Value = 0 
Else 
    objSQLParms(12).Value = val(cmbemployee.Text.Trim.Substring(0, 1)) 
End If 
0

,因为当你火按钮的事件中插入到数据库 的页面回来后 并设置为默认组合框的值“A”

您可以通过投放组合框在更新面板 解决问题避免重新加载页面