下面列出的是“.aspx.vb”文件中的代码。但是,它不连接到 SQL 2008 DB。代码中有错误吗?是否有执行下面列出的存储过程的替代方法?感谢您的预期答复。
Dim con As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("ConStr").ToString())
Dim cmd As New SqlCommand
con.Open()
Dim units As TextBox = DirectCast(e.Item.FindControl("txtUnits"), TextBox)
Dim weight As TextBox = DirectCast(e.Item.FindControl("txtWeight"), TextBox)
Dim length As TextBox = DirectCast(e.Item.FindControl("txtLength"), TextBox)
Dim height As TextBox = DirectCast(e.Item.FindControl("txtHeight"), TextBox)
Dim width As TextBox = DirectCast(e.Item.FindControl("txtWidth"), TextBox)
Dim fclass As RadComboBox = DirectCast(e.Item.FindControl("ddlFreightClass"), RadComboBox)
cmd = New SqlCommand("spShipmentsLineValueInsert", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New SqlParameter("@LoadNumber", Convert.ToInt64(Session("loadNumber"))))
cmd.Parameters.Add(New SqlParameter("@Units", Convert.ToInt16(units.Text)))
cmd.Parameters.Add(New SqlParameter("@Weight", Convert.ToDecimal(weight.Text)))
cmd.Parameters.Add(New SqlParameter("@Length", Convert.ToDecimal(length.Text)))
cmd.Parameters.Add(New SqlParameter("@Width", Convert.ToDecimal(width.Text)))
cmd.Parameters.Add(New SqlParameter("@Height", Convert.ToDecimal(height.Text)))
cmd.Parameters.Add(New SqlParameter("@FreightClass", fclass.SelectedItem.Text))
cmd.Parameters.Add(New SqlParameter("@DefaultMeasure", defaultMeasure))
cmd.Parameters.Add(New SqlParameter("@SessionID", userCode))
Dim RetVal As String = cmd.ExecuteNonQuery()
con.Close()