我有一个带有复合键的表,以及一个附加字段。使用标准生成的jOOQ DAO,如何删除记录?
API需要一个Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Using System.Windows.Forms;
Using System.Collections;
Using System.Data.SqlClient;
namespace TakNet
{
public partial class Form2 : Form
{
SqlConnection con = New SqlConnection(@"Data Source=DEV6-PC; Initial
Catalog=Tak_Net;Integrated Security=True;");
ComboBox combo;
Public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
// TODO: This line Of code loads data into the 'p_Cat2._P_Cat2'
table.You can move, Or remove it, as needed.
this.p_Cat2TableAdapter.Fill(this.p_Cat2._P_Cat2);
// TODO: This line Of code loads data into the 'p_Cat._P_Cat' table.
You can move, or remove it, as needed.
this.p_CatTableAdapter.Fill(this.p_Cat._P_Cat);
this.final_Cat_GlobalTableAdapter.Fill(this.finalCatGlobal.Final_Cat_Global);
}
private void dataGridView1_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
//GET OUR COMBO OBJECT
combo = e.Control as ComboBox;
if (combo != null)
{
// AVOID ATTACHMENT TO MULTIPLE EVENT HANDLERS
combo.SelectedIndexChanged -= New
EventHandler(combo_SelectedIndexChanged);
//THEN NOW ADD
combo.SelectedIndexChanged += combo_SelectedIndexChanged;
}
}
private void combo_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
if (((sender as ComboBox).SelectedValue.ToString() != null) &&
((sender as ComboBox).SelectedValue != null) && ((sender as
ComboBox).SelectedValue.ToString() != "System.Data.DataRowView") &&
((sender
as
ComboBox).SelectedValue.ToString() != "-1"))
{
string selected = (sender as
ComboBox).SelectedValue.ToString();
MessageBox.Show(selected);
DataSet loadData1()
{
MessageBox.Show("check1");
//con.Open();
SqlDataAdapter adapter = new SqlDataAdapter();
SqlCommand cmd;
DataSet ds = new DataSet();
//SELECT STMTS
String P_SubCat = "SELECT SubCat FROM dbo.P_Cat where
Cat = '" + selected + "' ";
MessageBox.Show(P_SubCat);
//Final TABLE
cmd = new SqlCommand(P_SubCat, con);
adapter.SelectCommand = cmd;
adapter.Fill(ds, "P_SubCat");
//P_SubCat TABLE
//adapter.SelectCommand.CommandText = P_SubCat;
//adapter.Fill(ds, "P_SubCat");
dt = ds.Tables[0];
return ds;
}
loadData1();
P_SubCat.DataSource = dt;
}
}
catch (Exception)
{
//MessageBox.Show("The Selected Row Is Empty");
}
}
}
,但是我不确定如何创建一个?这是我目前正在做的事情:
Record2
我不喜欢我需要向最后一个字段提供一些虚假数据。
是否有更优雅的方法?
答案 0 :(得分:2)
目前,除了以下两种方法外,别无其他方法:
按如下所示提供Record2
类型
ctx.newRecord(TABLE.COL1, TABLE.COL2).values(key1Uuid, key2Uuid)