你好,我正试图在没有匹配的学生时犯错......它会显示如下这个
No matching records found,我希望列名仍然相同,但仍然没有把它搞清楚......有人可以告诉我这是不是对??
继承我的功能......我在那里添加评论我把错误...但我不知道如何获得列名
public void SearchTableStudent() {
String tempSearchValue = searchStudent.getText().trim();
boolean empty = true;
sql = "SELECT student_id as 'Student ID',"
+ "concat(lastname, ' , ', firstname, ' ', middlename) as 'Name'"
+ "FROM user "
+ "WHERE CAST(student_id as CHAR) LIKE '%" + tempSearchValue + "%'";
try {
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
while(rs.next()) {
table.setModel(DbUtils.resultSetToTableModel(rs));
empty = false;
}
if(empty) {
String error = "";
table.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{"No …Run Code Online (Sandbox Code Playgroud) 我试图在我的另一个表上添加外键但这给了我错误
#1072 - Key column 'role_id' doesn't exist in table
你好我已经创建了一个名为的表 role
然后我就是这样创造的
create table role (
role_id varchar(15)
primary key (role_id)
)
Run Code Online (Sandbox Code Playgroud)
然后当我试图改变我user桌子上的桌子时
alter table user
add foreign key (role_id)
references role(role_id)
Run Code Online (Sandbox Code Playgroud)
我收到了这样的错误
#1072 - Key column 'role_id' doesn't exist in table
对不起是菜鸟..

我用这样d.PODate.ToString()来显示(见图)我可以使用inspect元素看到它...我想只显示日期而不是时间,当我尝试使用d.PODate.ToString("d")它时给了我这样的错误Method 'System.String ToString(System.String)' has no supported translation to SQL
并且同样d.PODate.ToShortDateString()得到这样的错误Method 'System.String ToShortDateString()' has no supported translation to SQL.
编辑
这是我的GET方法
[HttpGet]
public Models.SysDataTablePager Get()
{
NameValueCollection nvc = HttpUtility.ParseQueryString(Request.RequestUri.Query);
string sEcho = nvc["sEcho"].ToString();
int iDisplayStart = Convert.ToInt32(nvc["iDisplayStart"]);
string sSearch = nvc["sSearch"].ToString();
int iSortCol = Convert.ToInt32(nvc["iSortCol_0"]);
string sSortDir = nvc["sSortDir_0"].ToString();
var BranchId = Convert.ToInt32(((wfmis.Global)HttpContext.Current.ApplicationInstance).CurrentBranchId);
var Count = db.TrnPurchaseOrders.Where(d => d.MstUser.Id == secure.GetCurrentUser() &&
d.MstBranch.Id == BranchId).Count();
var PurchaseOrders = from d in db.TrnPurchaseOrders …Run Code Online (Sandbox Code Playgroud)