我想用以下类型的值解析一个字段:
"DAVE EBERT CONSTRUCTION~139 LENNOX STREET~SANTA CRUZ,CA 95060 ~~商业电话:(831)818-3170"
我想做一个像这样的查询:
Update mytable set street = string_to_array(myfield,'~')[2]
Run Code Online (Sandbox Code Playgroud)
但string_to_array不会"返回"一个数组,因此无法以这种方式链接.但是,它确实返回一个数组,可以被其他函数使用,这些函数接受像array_upper()这样的数组,因此我不知道为什么它不起作用.
我的解决方法是创建一个数组字段并执行以下操作:
Update mytable set myfield_array = string_to_array(myfield,'~')
Update mytable set street = myfield_array[2]
Run Code Online (Sandbox Code Playgroud)
有没有更直接的方法来做到这一点?但同样,如果我提取了许多不同的数组元素,也许不那么直接的方式表现得更好,因为你只将字符串转换为数组一次?
我有一个正在开发中的Azure网站,可连接到新的Azure Postgresql数据库。
这个错误似乎是在周末开始的。上次我上周五尝试时,它运行良好。我的Azure网站计划的IP地址似乎已更改,因此我编辑了Azure Postgres防火墙规则。
真正奇怪的部分是“ 0.0.0.0”主机。Web服务器对数据库的IP地址为“ 0.0.0.0”的样子如何?我确实也向防火墙添加了“ 0.0.0.0”,但这没有任何效果。我当然不能直接在Azure上编辑pg_hba.conf文件。
另外,从我的开发计算机运行时,它也可以正常工作。我尝试重新部署我的网站,没有任何乐趣。
这是完整的堆栈跟踪:
[PostgresException (0x80004005): 28000: no pg_hba.conf entry for host "0.0.0.0", user "UserName", database "orders", SSL on]
Npgsql.NpgsqlConnector.DoReadMessage(DataRowLoadingMode dataRowLoadingMode, Boolean isPrependedMessage) +310
Npgsql.NpgsqlConnector.ReadMessageWithPrepended(DataRowLoadingMode dataRowLoadingMode) +195
Npgsql.NpgsqlConnector.HandleAuthentication(String username, NpgsqlTimeout timeout) +57
Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout) +299
Npgsql.ConnectorPool.Allocate(NpgsqlConnection conn, NpgsqlTimeout timeout) +573
Npgsql.NpgsqlConnection.OpenInternal() +366
Npgsql.NpgsqlConnection.Open() +4
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +120
System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) +160
System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +108
MapHazardsPro4.Functs.GetUserTable() …Run Code Online (Sandbox Code Playgroud) 我需要从用VB.Net编写的Windows服务锁定工作站.我在Windows 7上编写应用程序,但它也需要在Vista和XP下运行.
User32 API LockWorkStation不起作用,因为它需要一个交互式桌面,我的返回值为0.
我尝试从进程和Shell中调用%windir%\ System32\rundll32.exe user32.dll,LockWorkStation,但仍然没有任何反应.
将服务设置为与桌面交互是不行的,因为我在管理员帐户下运行服务,因此它可以执行一些需要管理员权限的其他内容 - 例如禁用网络,并且您只能选择与桌面交互选项如果在本地系统帐户下运行.
这将是次要问题 - 如何在本地系统帐户下运行的服务中运行具有管理员权限的另一个应用程序而不会引起用户烦扰.
我正在编写一个应用程序来控制我的孩子计算机/互联网访问(我计划在完成后开源)所以我需要尽可能隐秘地发生一切.
我有一个UI来处理任务栏中的设置和状态通知,但这很容易被杀死,从而打败锁定.我可以制作另一个隐藏的Windows窗体应用程序来处理锁定,但这似乎是一个相当不优雅的解决方案.
谁有更好的想法?
因此,我正在运行一个简单的选择查询:
Private Function ReturnTableQuery(ByVal SQL As String) As DataTable
Dim rs As DataTable = New DataTable
Dim Adapter As NpgsqlDataAdapter = New NpgsqlDataAdapter
Try
If conn Is Nothing Then
ConnectDatabase()
End If
If conn.State <> ConnectionState.Open Then
ConnectDatabase()
End If
Adapter.SelectCommand = New NpgsqlCommand(SQL, conn)
Adapter.SelectCommand.CommandTimeout = 10
Adapter.Fill(rs)
Catch ex As Exception
PreserveStackTrace(ex)
Throw ex
End Try
Return rs
End Function
Run Code Online (Sandbox Code Playgroud)
SQL命令是:
Select id, application, datetimestamp, status, data, attemptcount from queue where application='reportengine' and status=4 and datetimestamp <= now() …Run Code Online (Sandbox Code Playgroud)