Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net “如何修复错误”初始化字符串的格式不符合从索引0开始的规范_.net_Vb.net - Fatal编程技术网

.net “如何修复错误”初始化字符串的格式不符合从索引0开始的规范

.net “如何修复错误”初始化字符串的格式不符合从索引0开始的规范,.net,vb.net,.net,Vb.net,在以下脚本下运行时,我遇到以下错误: 初始化字符串的格式不符合从索引0开始的规范 你能帮我解决这个问题吗 代码如下 <BaseObjectTypeAttribute("PwOHelperPwO")> _ Public Function CCC_GetProductIdent( ByVal dbPwOHelperPwO As ISingleDbObject) As String Dim scriptErrorBase As String = "Sc

在以下脚本下运行时,我遇到以下错误:

初始化字符串的格式不符合从索引0开始的规范

你能帮我解决这个问题吗

代码如下

<BaseObjectTypeAttribute("PwOHelperPwO")> _
Public Function CCC_GetProductIdent( ByVal dbPwOHelperPwO As ISingleDbObject) As String
    Dim scriptErrorBase As String = "Script Error [CCC_GetProductIdentfromRequest]"
    Dim returnValue As iDatareader
    Dim results As New StringBuilder
    Dim connData As ConnectData = DbApp.Instance.Connect(VID_GetValueOfDialogdatabases("ConnectionString"))
    Dim cSQL As SqlExecutor = Connection.CreateSqlExecutor(connData.PublicKey)
    Dim pwoUID As String = dbPwoHelperPwo.GetValue("UID_PersonWantsOrg")
    
    Dim myQuery As String = String.Format("select " &
                            "apg.Ident_AccProductGroup " &
                            "from PersonWantsOrg pwo" &
                            " inner join QERAssign qas" &
                            "  On pwo.ObjectKeyOrdered = qas.XObjectKey" &
                            " inner join AccProduct apd" &
                            "  On qas.UID_AccProduct = apd.UID_AccProduct" &
                            " inner join AccProductGroup apg" &
                            "  On apd.UID_AccProductGroup = apg.UID_AccProductGroup " &
                            "where pwo.UID_PersonWantsOrg = '{0}'",pwoUID)
    Try
        returnValue = cSQL.SqlExecute(String.Format(myQuery))
            
        While returnValue.Read()
              results.Append(returnValue("Ident_AccProductGroup").ToString)            
        End While
    Catch ex As Exception
        Throw New Exception(String.Format("{0} {1} {2}", scriptErrorBase, myQuery, ex))
    End Try
    
    Return results.ToString
    
End Function

我认为这是因为SqlExecuteString.FormatmyQuery。因为您已经调用了String.Format来获取myQuery,所以可以删除对String.Format的第二次调用。所以只需returnValue=cSQL.SqlExecutemyQueryI在删除string.fromat后再次编译,但运气不好。您能再看一次吗?还要注意的是,我的数据库是加密的,所以连接字符串有任何问题吗?可能是连接字符串中的错误,所以我的一个副本通过了链接,但它对我没有帮助。如何解密我的连接?