请看下面的截图...
我想知道,将 DataGridView 中的所有数据存储到列的最佳方法是什么?此数据特定于一个客户而不是其他任何人,因此这就是为什么我希望它存储在该客户的特定列中......我使用 SQL Server 2008R2 和带有参数的存储过程,以备不时之需。如果有人可以提供在 vb.net 中设置的示例,我将不胜感激!
这是我的函数,除了 datagridview 数据之外,它可以保存...
'Save the invoice to later reference it'
Public Shared Function SaveInvoice(ByVal strInvDate As String, ByVal customerID As Integer, ByVal strCustomerName As String, ByVal strHTML As String, ByVal invoiceID As Integer) As Integer
Dim Conn As String = "Data Source=localhost\sqlexpress;Initial Catalog=NuTech;Integrated Security=True"
Dim oParam As SqlParameter() = { _
New SqlParameter("@" & CustomerDocumentConstants.CUSTOMER_ID, customerID), _
New SqlParameter("@" & CustomerDocumentConstants.INVOICE_DATE, strInvDate), _
New SqlParameter("@" & CustomerDocumentConstants.CUSTOMER_NAME, strCustomerName), _
New SqlParameter("@" & CustomerDocumentConstants.INVOICE_HTML, strHTML), _
New SqlParameter("@" & CustomerDocumentConstants.INVOICE_ID, invoiceID), _
New SqlParameter("@New_" & CustomerDocumentConstants.INVOICE_ID, 0)
}
oParam(oParam.Length - 1).Direction = ParameterDirection.Output
Try
SQLHelper.ExecuteNonQuery(Conn, CommandType.StoredProcedure, SAVE_INVOICE, oParam)
If oParam(oParam.Length - 1).Value IsNot DBNull.Value Then
invoiceID = oParam(oParam.Length - 1).Value
End If
Catch ex As Exception
'Just catch it for all I care!"
End Try
Return invoiceID
End Function
在我的参数中显示 INVOICE_HTML、strHTML 的地方:如果可能的话,我想用它来保存来自 datagridview 的数据。如果您需要任何帮助,请告诉我!
谢谢!