怎么实现这个功能?
在datagridview中显示出来的数据行列中,随意选中一行,然后点击界面上的提交按键,实现把该记录提交到数据库的另外一张表,这个功能试了很多次都没有实现,有没有高手啊,跪求代码啦!!!!!!!!!!!!!!
[解决办法]
public int AddGpsBarcode(int CustomerID, string BarcodeNO, int Type) { try { string sqlStr = "insert into Tab_CustomerBarcode(CB_ID,CB_CustomerID,CB_BarcodeNO,CB_Type,CB_State,CB_UpdateTime) values (@newGuid,@CustomerID,@BarcodeNO,@Type,0,@UpdateTime)"; sqlCommand = new SqlCommand(sqlStr, sqlConnection); sqlCommand.Parameters.Add(new SqlParameter("@newGuid", SqlDbType.UniqueIdentifier, 16)); sqlCommand.Parameters["@newGuid"].Value = Guid.NewGuid(); sqlCommand.Parameters.Add(new SqlParameter("@CustomerID", SqlDbType.Int, 4)); sqlCommand.Parameters["@CustomerID"].Value = CustomerID; sqlCommand.Parameters.Add(new SqlParameter("@BarcodeNO", SqlDbType.VarChar, 50)); sqlCommand.Parameters["@BarcodeNO"].Value = BarcodeNO; sqlCommand.Parameters.Add(new SqlParameter("@Type", SqlDbType.Int, 4)); sqlCommand.Parameters["@Type"].Value = Type; sqlCommand.Parameters.Add(new SqlParameter("@UpdateTime", SqlDbType.DateTime, 8)); sqlCommand.Parameters["@UpdateTime"].Value = DateTime.Now; return sqlCommand.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } finally { if (sqlCommand != null) { sqlCommand.Dispose(); } sqlConnection.Close(); } }