在这里,我们将给大家分享关于在插入SQL数据库时,为什么我的字符串值会累积空格?的知识,让您更了解sql字符串出现次数的本质,同时也会涉及到如何更有效地c#–在插入数据库时将空字符串设置为null、c
在这里,我们将给大家分享关于在插入SQL数据库时,为什么我的字符串值会累积空格?的知识,让您更了解sql字符串出现次数的本质,同时也会涉及到如何更有效地c# – 在插入数据库时将空字符串设置为null、css – 为什么我的HTML元素之间会出现空格?、delphi – 插入UTF8数据库时格式错误的字符串、DW中链接mysql数据库时,建立字符集中文出现乱码的解决方法的内容。
本文目录一览:- 在插入SQL数据库时,为什么我的字符串值会累积空格?(sql字符串出现次数)
- c# – 在插入数据库时将空字符串设置为null
- css – 为什么我的HTML元素之间会出现空格?
- delphi – 插入UTF8数据库时格式错误的字符串
- DW中链接mysql数据库时,建立字符集中文出现乱码的解决方法
在插入SQL数据库时,为什么我的字符串值会累积空格?(sql字符串出现次数)
我将一个广泛的表单插入到SQL数据库中,然后从管理页面中请求所有数据,并将其重新插入到管理页面上的表单中。在最初插入数据库的过程中,此特定的下拉列表(就像其他列表一样)正在插入选定的数据。但是,当我进入数据库时,仅此特定单元格在插入所选值后将获得3到4个空白空间。这会导致布尔比较在尝试重新插入管理员表单时以false做出响应。即(“
Primary” ==“ Primary”)= false。因此,下拉列表未更新。
是什么导致SQL行添加这些空白?该代码对于所有HTML下拉列表均相同,但其代码位于后面。而且,SQL数据库的结构在整个过程中似乎也是相同的。
ps为了解决这个问题,我尝试在后面的代码中使用.Trim()。但这并没有改变。似乎SQL数据库在插入时添加了空白。
c# – 在插入数据库时将空字符串设置为null
try { using (sqlConnection cn = new sqlConnection(ConfigurationManager.ConnectionStrings["AbleCommerce"].ToString())) { cn.open(); sqlCommand cmd = new sqlCommand(); cmd.Connection = cn; cmd.Parameters.Add(new sqlParameter("@FIPSCountyCode",countyCodeTxt.Text)); cmd.Parameters.Add(new sqlParameter("@StateCode",stateCodeList.SelectedValue)); cmd.Parameters.Add(new sqlParameter("@CountyName",countyNameTxt.Text)); string taxStr = taxRateTxt.Text; //test for an empty string and set it to db null if (taxStr == String.Empty) { taxStr = dbnull.Value; } cmd.Parameters.Add(new sqlParameter("@TaxRate",taxStr)); if (AddBtn.Visible == true) cmd.CommandText = addQuery; if (EditBtn.Visible == true) { cmd.CommandText = editQuery; } cmd.ExecuteNonQuery(); cn.Close(); }
我在这里错过了什么?
解决方法
string taxStr = taxRateTxt.Text; //test for an empty string and set it to db null if (taxStr == String.Empty) { taxStr = dbnull.Value; }
并改变这一点
cmd.Parameters.Add(new sqlParameter("@TaxRate",taxStr));
对此
cmd.Parameters.Add(new sqlParameter("@TaxRate",string.IsNullOrEmpty(taxRateTxt.Text) ? (object)dbnull.Value : taxRateTxt.Text));
css – 为什么我的HTML元素之间会出现空格?
还有第二个问题 – 为什么我的黑色边框也不包括主要内容?我认为,因为它的身体背景,它会绕过身体的每个元素.
我意识到可能有类似的问题,但我无法在任何地方找到答案.我会感激任何人的意见 – 这是我在这里发表的第一篇文章,所以如果我搞砸任何格式,我很抱歉.
我的网站图片可以在这里找到:
http://postimage.org/image/20dhjcdb8/
提前致谢.
我目前在index.html文件中有以下代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="swaggeRSStyle.css"> <title>Oamaru Backpackers Hostel,Swaggers Backpackers - Home</title> </head> <body> <img src="final.jpg" id="banner"></img> <ul id="nav"> <li><a href="index.html">Home</a></li> <li><a href="planning.html">Planning</a></li> <li><a href="construction.html">Construction</a></li> <li><a href="evaluation.html">Evaluation</a></li> </ul> <div id="mainc"> <p>Make Yourself at Home</p> <p>Swaggers Backpackers is a converted old house located within walking distance of all the best parts of Oamaru. Explore the old victorian era buildings and shops of the city centre,or see the penguin colonies down the street. Swaggers is owned and operated by camp mum Agra,who makes all guests feel welcome,informed,and perhaps a bit mothered. </p> </div> </body> </html>
和以下CSS代码:
html{ font-family: sans-serif; background-color:#464E54; } body{ width: 960px; margin: auto; background-color: white; border: 5px solid black; } #banner{ padding: 0px; margin: 0; } #nav { list-style-type: none; padding: 0px; margin: 0px; overflow: hidden; } #mainc { width: 960px; float: right; background-color: white; margin: 0; } .links { float: left; margin: 0px; } a:link,a:visited { display: block; width: 232px; font-weight: bold; color: grey; background-color: #dad8bf; text-align: center; padding: 4px; text-decoration: none; text-transform: uppercase; margin-top: 0px; } a:hover,a:active{ background-color: #333333; }
解决方法
The problem that I am having is between my banner image and my navbar there is a blank white line that you can see in the image. I thought this is to do with the margin so I have set it to zero for both of the elements to no avail.
在HTML图像中默认为内联级别元素,因此它们遵循文本规则(并且下面将有空白区域以保持与“p”等字母的正确对齐).您可以将display:block指定给标题图像,也可以将标题容器定义为与图像具有相同的精确高度
Also a second question – Why does my black border not cover the main content as well? I thought since its a body background it would go around every element in the body.
因为浮动元素从容器中弹出,所以必须清除浮动以使用类似的东西扩展容器
<div></div>
或者使用一些reset / clearfix css,例如html5boilerplate提供的css.
delphi – 插入UTF8数据库时格式错误的字符串
数据库字符集是UTF8.在db-connection UTF8中.
数据库:
var Database: TIBDatabase; begin ... Database.params.Clear; Database.params.Add('user ''SYSDBA'' password ''masterkey'' '); Database.params.Add('page_size 16384'); Database.params.Add('default character set UTF8');
表:
CREATE TABLE NEW_TABLE ( NEW_FIELD VARCHAR(255) );
连接代码:
Database.params.Clear; Database.params.Add('user_name=SYSDBA'); Database.params.Add('password=masterke'); Database.params.Add('sql_role_name=UTF8'); Database.Open;
插入代码:
var IBsql: TIBsql; begin IBsql := TIBsql.Create(nil); try IBsql.Database := db; IBsql.Transaction := tr IBsql.sql.Text := 'insert into NEW_TABLE (NEW_FIELD) values (:param)'; IBsql.params[0].Value := 'Ãabc©'; // unsupported symbols :( if not IBsql.Transaction.Active then IBsql.Transaction.StartTransaction; IBsql.ExecQuery; // "Malformed string" exception here if IBsql.Transaction.Active then IBsql.Transaction.Commit; finally FreeAndNil(IBsql); end; end;
我收到“格式错误的字符串”异常.如何插入此字符串?
解决方法
创建新字段时,您有两个选择:
>使用默认字符集创建域并进行整理,并使用域设置字段
>创建不带域的字段,设置字符集并手动整理.
在下图中,显示使用IBExpert使用域创建的字段.
DW中链接mysql数据库时,建立字符集中文出现乱码的解决方法
只是中文出现乱码时,在链接数据库后面,加上这一句
utf8的话
gbk的话
mysql_query("SET NAMES ''gbk''");
今天关于在插入SQL数据库时,为什么我的字符串值会累积空格?和sql字符串出现次数的分享就到这里,希望大家有所收获,若想了解更多关于c# – 在插入数据库时将空字符串设置为null、css – 为什么我的HTML元素之间会出现空格?、delphi – 插入UTF8数据库时格式错误的字符串、DW中链接mysql数据库时,建立字符集中文出现乱码的解决方法等相关知识,可以在本站进行查询。
本文标签: