我忘了或错误输入(在安装过程中)密码给Postgres的默认用户.我似乎无法运行它,我收到以下错误:
psql: FATAL: password authentication failed for user "hisham"
hisham-agil: hisham$ psql
Run Code Online (Sandbox Code Playgroud)
是否有重置密码或如何创建具有超级用户权限的新用户?
我是Postgres的新手,刚刚第一次安装它.我正在尝试使用它与Rails,我正在运行Mac OS X Lion.
我有一个简单的表格,如下所示。
create table chemlab.rule_header (
id serial PRIMARY KEY,
name varchar(50),
grade varchar(20),
class_tag varchar(20), --tag added to sammple if match
parent_id int REFERENCES chemlab.rule_header(id) DEFAULT NULL,
unique( grade, class_tag )
)
Run Code Online (Sandbox Code Playgroud)
但是之后,我发现我需要添加ON DELETE
操作,默认值为NO ACTION
。我不知道如何更改操作。
现在我必须DROP
&ADD
ALTER table chemlab.rule_header
DROP CONSTRAINT rule_header_parent_id_fkey ;
ALTER TABLE rule_header
ADD CONSTRAINT rule_header_parent_id_fkey
FOREIGN KEY (parent_id) REFERENCES chemlab.rule_header(id) ON DELETE RESTRICT;
Run Code Online (Sandbox Code Playgroud)
那么,改变对外键约束的操作的正确语法是什么?
我有一个使用DataReader作为其数据源的DataGrid.我想隐藏数据网格的第一列.我正在使用.net紧凑框架3.5.我可以找到Windows窗体的示例,但api已经改变,它们不起作用.
只是尝试使用string.Format()
将系统MAC地址转换为文本格式.但它不起作用:
byte[] MacAddr = new byte[6];
// this works, but rather clumzy
mac = string.Format("{0:X2}-{1:X2}-{2:X2}-{3:X2}-{4:X2}-{5:X2}",
MacAddr[0], MacAddr[1], MacAddr[2], MacAddr[3], MacAddr[4], MacAddr[5]);
// give me index error
mac = string.Format("{0:X2}-{1:X2}-{2:X2}-{3:X2}-{4:X2}-{5:X2}", MacAddr);
Run Code Online (Sandbox Code Playgroud)
EDIT1:OK,我错了,但似乎string.format
对于工作这家伙的情况下用string[]
.
我可以看到有一种重载方法string.format
:
Format(String, array<Object>[]()[])
.是否有可能创建某种形式的byte [],可以这样做array<Object>[]()[]
?
我有一个从Cpp程序获取的字节数组。
arr[0..3] // a real32,
arr[4] // a uint8,
Run Code Online (Sandbox Code Playgroud)
我怎么解释arr[4]
为int
?
(uint)arr[4] // Err: can't implicitly convert string to int.
BitConverter.ToUint16(arr[4]) // Err: Invalid argument.
buff[0+4] as int // Err: must be reference or nullable type
Run Code Online (Sandbox Code Playgroud)
我是否必须将连续字节清零才能将其解释为UInt16
?
好,这是混乱。最初,我定义了我的课程。
byte[] buff;
buff = getSerialBuffer();
public class Reading{
public string scale_id;
public string measure;
public int measure_revised;
public float wt;
}
rd = new Reading();
// !! here is the confusion... !!
// Err: Can't …
Run Code Online (Sandbox Code Playgroud) 我创建了一个验证函数,如下所示:
public static T getAsDigit<T>( this Textbox tb, float min, float max ){
}
Run Code Online (Sandbox Code Playgroud)
大多数情况下,验证范围以整数指定。它工作正常。但是当我尝试传入小数时,它给了我错误之类的can't convert double to float
,我必须将定义更改为双倍。
我是 C# 新手,如何将数字作为 float 传递?不做不直观之类的Convert.toFloat('1.3')
。
我的用例只需要 3 个小数位精度,值范围 0.000 ~ 10.000。在 C# 中使用 float 和 double 有什么缺点吗?自从我使用并看到人们在 sql 中使用 float 时,decimal() 是可选的。
c# ×4
postgresql ×2
.net ×1
.net-3.5 ×1
bytebuffer ×1
constraints ×1
datagrid ×1
decimal ×1
foreign-keys ×1
sql ×1
uint8t ×1