为什么使用定义列表(DL,DD,DT)代替HTML表单而不是表格?(Why use definition lists (DL,DD,DT) tags for HTML forms instead of tables?)
最近我遇到了一些例子:
<dl> <dt>Full Name:</dt> <dd><input type="text" name="fullname"></dd> <dt>Email Address:</dt> <dd><input type="text" name="email"></dd> </dl>
做HTML表单。 这是为什么? 使用表有什么优势?
I've come across a few examples recently that do things like:
<dl> <dt>Full Name:</dt> <dd><input type="text" name="fullname"></dd> <dt>Email Address:</dt> <dd><input type="text" name="email"></dd> </dl>
for doing HTML forms. Why is that? What is the advantage over using tables?
原文:https://stackoverflow.com/questions/519234
最满意答案
在字符串之前使用@时,不需要再次转义反斜杠。 LIKE的占位符是%,而不是*。
所以尝试:
string query = @"SELECT COUNT(*) FROM table WHERE path LIKE '%\\\\server\\dir\\%'";
要避免所有转义,请考虑使用SQL参数。
PS:table是保留关键字。 您不应该为表格命名,这将始终导致问题。
So Ms Access use * as a wildcard like T_D indicated and which is what my valide query use in MS Access. BUT like HansUp indicated C# OleDb API still uses ANSI wild cards.
But small correction even to that answer would be to escape the query in c#. So query returning valid answer is:
string query = "SELECT COUNT(*) FROM Settings WHERE path LIKE '%\\\\server\\dir\\%'"; OR string query = @"SELECT COUNT(*) FROM Settings WHERE path LIKE '%\\server\dir\%'"; -> returns Count(*) = 3
HansUp also pointed that using ALIKE instead of LIKE % also works in MS Access so that way query is compatible with ANSI wildcard %
So here is my working solution (with command parameters):
string destFolder = @"\\server\\dir\"; string query = "SELECT COUNT(*) FROM Settings WHERE path LIKE @destFolder;"; using (OleDbConnection connection = new OleDbConnection(mdbfile)) { using (OleDbCommand command = new OleDbCommand(query, connection)) { command.Parameters.AddWithValue("@destFolder", "%" + destFolder + "%"); try { connection.Open(); if ((int)command.ExecuteScalar() == 3) { return true; } else { return false; } } catch (OleDbException ex) { //handle OleDb error return false; } } }
相关问答
更多-
在字符串之前使用@时,不需要再次转义反斜杠。 LIKE的占位符是%,而不是*。 所以尝试: string query = @"SELECT COUNT(*) FROM table WHERE path LIKE '%\\\\server\\dir\\%'"; 要避免所有转义,请考虑使用SQL参数。 PS:table是保留关键字。 您不应该为表格命名,这将始终导致问题。 So Ms Access use * as a wildcard like T_D indicated and which is what ...
-
SQL到MS Access SQL查询(SQL To MS Access SQL Query)[2022-03-03]
您正在尝试为每个pk_id获取第一条记录(基于Field1 )。 这样的事可能适合你: select p.* from table1 as p where p.field1 = (select max(p2.field1) from table1 as p2 where p2.pk_id = p.pk_id ); You are trying to get the first record (base ... -
我强烈建议你只是忘记not in使用子查询。 相反,使用not exists : Select [ID] from table1 as t1 where NOT EXISTS (SELECT 1 FROM table2 as t2 WHERE t2.id = t1.id); 如你所知,当子查询返回NULL时, not in有错误的语义(即行为)。 不要试图使其工作,只需使用NOT EXISTS 。 另外一个好处是,这很容易扩展到多列,并且如果可用的话应该使用索引。 I strongly recommend ...
-
不要像字符串那样处理日期。 没有例外。 在这里你可以使用: RDATE: DateValue([RENEWAL_DATE]) Don't ever handle dates like strings. No exceptions. Here you can use: RDATE: DateValue([RENEWAL_DATE])
-
MS访问SQL查询(MS Access to SQL Query)[2022-01-23]
我不确定,但我认为这是你的意图: --Combined Query1&2 in SQL SELECT DISTINCT [TableA].Mat, [TableA].Sg, ISNULL([TableA].Pt, [TableC].Pt) AS Pln, [TableB].[Ptype] INTO #FINAL FROM [TableA] INNER JOIN [TableB] ON [TableA].Sg = [TableB].Sg INNER JOIN [TableC] ... -
MS SQL Excel查询通配符(MS SQL Excel Query wildcards)[2023-08-25]
看看这个引用 ,它表明%本身是通配符,虽然它可能取决于你正在使用的SQL的方言。 如果是这种情况,那么您的LIKE子句将只是LIKE '%'但未经测试。 My query was correct. There was something wrong with the actual spreadsheet. After redoing all from scratch - it worked! SELECT Elen_SalesData_View.ItemCode, Elen_SalesData_View.I ... -
您的访问代码 Where Field = Date() Sql Server Where Field = CAST(GETDATE() AS DATE) 函数GETDATE()获取当前的Datetime。 今天和过去7天之间的日期 Where Field BETWEEN CAST(DATEADD(DAY, -7, GETDATE()) AS DATE) AND CAST(GETDATE() AS DATE) 我使用CAST()函数的原因是因为GETDATE( ...
-
MS Access有条款(MS Access Having Clause)[2022-07-26]
确定...导致类型不匹配是因为tblmt.mtdate不是日期字段或者tblmt.hours不是数字字段而且您的数据不是日期,也不是客户的数字不像'TEST *'。 或者,对于某些客户,mt.date中的NULL为null,而null不能与> =进行比较。 如果你说tblMt.cust不喜欢“TEST *”,你仍会得到错误。 问题可能与数据或您的期望有关,您需要处理它。 什么数据类型是tblMT.hours和tblMt.MtDate? Ok... the type mismatch is caused be ... -
我无权访问MS, 但是我会告诉你使用基本的SQL功能在MySql上做到这一点:JOIN + GROUP BY + MAX: SELECT t.Awardee, t.State, t.City, max( t.Year ) as Year FROM table1 t JOIN ( SELECt Awardee, State, City, max( Year ) as Year FROM table1 GROUP BY Awardee, State, City ) x ON x.Awardee = ...
-
你的意思是你正在尝试运行文本查询,就像在SSMS中一样? 我认为唯一需要转义的是'所以你应该能够选择文本块,并做一个find-replace来替换' with '' 。 注意:如果您是从代码运行它,那么您应该使用参数化查询,纯粹而简单。 You mean you're trying to run a text query, like in SSMS? I think the only thing that needs to be escaped is the ' so you should be able ...