Crystal Reports Missing Parameter Values - vb.net

I am running the version of crystal that comes with Visual Studio 2010. I have a report that has three sub reports. There are parameters that are passed from the main report to the sub-reports. I am able to run the report in the development environment by clicking on Main Report Preview.
The problem is when I try to execute it at run time. I get the error “Missing parameter values”. I need some hints as to how to debug this problem. The error doesn’t tell you which parameter is the problem or which sub-report is involved.
Any hint will be appreciated.
I am editing this to respond to some of the questions. I am using subreports links which is where I think the problem might be. In the pass by fiddling with the settings I was able to get it to work. It seems like it was just trial and error.
I am posting a portion of the code here based on the request in the comments
Public Function GetReportOutput(iDatabaseIndicator As eDatabaseIndicatorEnum, ReportName As String, ReportOutputtype As eReportOutputtype, ReportParameters As System.Collections.Generic.List(Of clsReportParam)) As clsReturn Implements IsvcEDReports.GetReportOutput
Dim l_crRep As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim l_clsReturn As clsReturn = New clsReturn
Dim l_ExportFormatType As ExportFormatType
Dim l_strReport As String = ""
Dim l_strReportName As String = ""
Dim l_strOutputFile As String = ""
Dim l_strFullPathName As String = ""
Dim l_strReportOutputPath As String = ConfigurationManager.AppSettings.Get(IIf(ConfigurationManager.AppSettings.Get("Environment") = 1, "ReportOutputPath_Dev", "ReportOutputPath_Prod"))
Dim l_strReportPath As String = ConfigurationManager.AppSettings.Get(IIf(ConfigurationManager.AppSettings.Get("Environment") = 1, "ReportPath_Dev", "ReportPath_Prod"))
Dim l_udtReport As CrystalDecisions.CrystalReports.Engine.ReportDocument = Nothing
Dim l_intCount As Integer = 0
Dim l_fsReturn As FileStream = Nothing
Dim l_binFilestream As BinaryReader = Nothing
Dim l_bytFile As Byte() = Nothing
Dim l_expOptions As New CrystalDecisions.Shared.ExportOptions
Dim l_expExcFmtOptions As New CrystalDecisions.Shared.ExcelFormatOptions
Dim l_tblParameters As New DataTable("Parameters")
Dim l_aryParams(1)
Dim udtSubReport As ReportDocument
Dim udtSubReportOpened As ReportDocument
Try
iDatabaseIndicator = iDatabaseIndicator
InitDataController(iDatabaseIndicator)
m_strReport = (l_strReportPath & "\" & ReportName)
l_strReportName = ReportName
l_strReport = m_strReport
l_strOutputFile = Regex.Replace(ReportName, " ", "_") & "_" & Format(Now(), "MMddyyyy_hhmmss")
m_strOutputFilename = l_strOutputFile
With l_crRep
.Load(l_strReport, CrystalDecisions.Shared.OpenReportMethod.OpenReportByDefault)
If .IsLoaded Then
For Each udtSubReport In .Subreports
udtSubReportOpened = .OpenSubreport(udtSubReport.Name)
SetDatabase(udtSubReportOpened, False)
SetParameters(udtSubReportOpened, ReportParameters, False)
Next
SetDatabase(l_crRep)
SetParameters(l_crRep, ReportParameters)
Select Case ReportOutputtype
'Case eReportOutputtype.rptOutputType_RPT
' l_strOutputFile = l_strOutputFile & ".rpt"
' l_ExportFormatType = ExportFormatType.CrystalReport
Case eReportOutputtype.rptOutputType_XLS
l_strOutputFile = l_strOutputFile & ".xls"
'ReportOutputFile = ReportOutputFile & ".xls"
With l_expExcFmtOptions
.ExcelConstantColumnWidth = 125
.ExcelUseConstantColumnWidth = True
End With
With l_expOptions
.ExportFormatOptions = l_expExcFmtOptions
End With
l_ExportFormatType = ExportFormatType.Excel
Case eReportOutputtype.rptOutputType_PDF
l_strOutputFile = l_strOutputFile & ".pdf"
' ReportOutputFile = ReportOutputFile & ".pdf"
l_ExportFormatType = ExportFormatType.PortableDocFormat
Case eReportOutputtype.rptOutputType_DOC
l_strOutputFile = l_strOutputFile & ".doc"
' ReportOutputFile = ReportOutputFile & ".doc"
l_ExportFormatType = ExportFormatType.WordForWindows
Case eReportOutputtype.rptOutputType_CSV
l_strOutputFile = l_strOutputFile & ".csv"
' ReportOutputFile = ReportOutputFile & ".csv"
l_ExportFormatType = ExportFormatType.CharacterSeparatedValues
Case eReportOutputtype.rptOutputType_TXT
l_strOutputFile = l_strOutputFile & ".txt"
' ReportOutputFile = ReportOutputFile & ".txt"
l_ExportFormatType = ExportFormatType.Text
Case eReportOutputtype.rptOutputType_XML
l_strOutputFile = l_strOutputFile & ".xml"
' ReportOutputFile = ReportOutputFile & ".xml"
l_ExportFormatType = ExportFormatType.Xml
End Select
.ExportToDisk(l_ExportFormatType, l_strReportOutputPath & "\" & l_strOutputFile)
It crashes on the last line .ExportToDisk ...

I solved this problem, It was the hint from heringer that gave me the clue. I am passing 6 parameters to the main report but two of them are only used by the a sub-report not the main reports itself. I was defining these without the leading "#". I figured this out by display the parameters as I passed them in my code.
I was also able to look at an old report that was working and saw that I needed the at signs.
Bob

Related

How to get file's path created by this code?

I'm using this code to save files in my app
Dim filePath = String.Format("image{0:yyyyMMddHHmmss}.png", DateTime.Now)
PictureBox1.Image.Save(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), (filePath)))
So now I have a textbox1 and I want to show the path of last saved image in it
how?
Regards,,,,
What I've done in the past is generate the path in one step and then use the generated variable to do the saving and to display.
So instead of:
Dim filePath = String.Format("image{0:yyyyMMddHHmmss}.png", DateTime.Now)
PictureBox1.Image.Save(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), (filePath)))
Try:
'Generate the Path
Dim path As String = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), String.Format("image{0:yyyyMMddHHmmss}.png", DateTime.Now))
'Save using the generated path
PictureBox1.Image.Save(path)
'Display the path
textbox1.Text = path
Thanks all I've done it successfully `
Dim filename As String = String.Format("image{0:yyyyMMddHHmmss}.png", DateTime.Now)
Dim filePath1 = (IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), (filename)))
Dim filePath2 = (IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), ("RMSS")))
If IO.Directory.Exists(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), (" RMSS"))) = True Then
TextBox1.Text = filePath1
TextBox2.Text = filePath2 & "\" & filename
PictureBox1.Image.Save(filePath1)
My.Computer.FileSystem.MoveFile(TextBox1.Text, TextBox2.Text, True)
Else
TextBox1.Text = filePath1
TextBox2.Text = filePath2 & "\" & filename
PictureBox1.Image.Save(filePath1)
My.Computer.FileSystem.MoveFile(TextBox1.Text, TextBox2.Text, True)
End If

Why can't my GetManifestResourceStream find my image?

I'm currently attempting to layer several images into a single composite, built from several body face pieces for a player's portrait.
Usually for grabbing images from the resources and putting them into a picturebox/etc I'd simply ".Image = My.Resources.ResourceManager.GetObject(filename)".
However I need to transfer to a Bitmap, which doesn't accept objects. I've found the below code from a couple of google results, but the file is bugging out as "Value of null is not valid for 'stream' ", and the pHead is "Nothing". As such I'm presuming the code can't find the file.
The break is causing on the final line of the below code.
Any help or simpler alternatives would be much welcome.
Dim GenderText As String = ""
Select Case ListCharacter(ActiveChar).Gender
Case eGender.Male : GenderText = "masc"
Case eGender.Female : GenderText = "fem"
End Select
Dim Prefix As String = ""
Dim Suffix As String = ".png"
Dim myAsm As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
' Load Head Image
' e.g. prt_fem_head_1_white.png
Dim headImageName As String = "prt_" & GenderText & "_head_" & CharApp.HeadStyle & "_" & CharApp.SkinColour
Dim pHead As Bitmap = New Bitmap(myAsm.GetManifestResourceStream(Me.GetType, headImageName & Suffix))
ps. Also bugs out with/without the suffix.
Edit #1;
I've found the prefix required, as far as I can tell, to the whereabouts of the resources root. However, that still isn't working to any variation.
Edit #2;
I've double checked the resource location via its properties.
"C:\Users\CLEO\Documents\Visual Studio 2015\Projects\Storytime\Storytime\Resources\prt_fem_head_1_white.png"
Solved. I changed the code out for a simpler one I found in my Resources Designer code. The below is very raw and needs tidying, but this is how I was able to make several images build into one picturebox.
' Load Face
Dim PortraitLocation As New Point(573, 51)
Dim CharApp As New Character.cAppearance : CharApp = ListCharacter(ActiveChar).Appearance
' Dim pHead, pEyes, pNose, pMouth, pBase, pHair As New PictureBox
Dim FaceCanvas As New PictureBox
Dim GenderText As String = ""
Select Case ListCharacter(ActiveChar).Gender
Case eGender.Male : GenderText = "masc"
Case eGender.Female : GenderText = "fem"
End Select
Dim resourceCulture As Global.System.Globalization.CultureInfo
Dim headImageName As String = "prt_" & GenderText & "_head_" & CharApp.HeadStyle & "_" & CharApp.SkinColour
Dim obj As Object = My.Resources.ResourceManager.GetObject(headImageName, resourceCulture)
Dim phead As Bitmap = CType(obj, System.Drawing.Bitmap)
Dim eyesImageName As String = "prt_" & GenderText & "_eyes_" & CharApp.EyeStyle & "_" & CharApp.SkinColour
Dim obj2 As Object = My.Resources.ResourceManager.GetObject(eyesImageName, resourceCulture)
Dim pEyes As Bitmap = CType(obj2, System.Drawing.Bitmap)
Dim noseImageName As String = "prt_" & GenderText & "_nose_" & CharApp.NoseStyle & "_" & CharApp.SkinColour
Dim obj3 As Object = My.Resources.ResourceManager.GetObject(noseImageName, resourceCulture)
Dim pNose As Bitmap = CType(obj3, System.Drawing.Bitmap)
Dim mouthImageName As String = "prt_" & GenderText & "_mouth_" & CharApp.MouthStyle & "_" & CharApp.SkinColour
Dim obj4 As Object = My.Resources.ResourceManager.GetObject(mouthImageName, resourceCulture)
Dim pMouth As Bitmap = CType(obj4, System.Drawing.Bitmap)
Dim hairImageName As String = "prt_" & GenderText & "_hair_" & CharApp.HairStyle & "_" & CharApp.HairColour
Dim obj5 As Object = My.Resources.ResourceManager.GetObject(hairImageName, resourceCulture)
Dim pHair As Bitmap = CType(obj5, System.Drawing.Bitmap)
Dim bodyImageName As String = "prt_" & GenderText & "_body_" & CharApp.SkinColour
Dim obj6 As Object = My.Resources.ResourceManager.GetObject(bodyImageName, resourceCulture)
Dim pBody As Bitmap = CType(obj6, System.Drawing.Bitmap)
Dim g As Graphics = Graphics.FromImage(pBody)
g.DrawImage(phead, 0, 0)
g.DrawImage(pEyes, 0, 0)
g.DrawImage(pNose, 0, 0)
g.DrawImage(pMouth, 0, 0)
g.DrawImage(pHair, 0, 0)
With FaceCanvas
.Location = PortraitLocation
.Size = New Size(50, 50)
.Image = pBody
.BackColor = Color.Transparent
End With
Me.Controls.Add(FaceCanvas)

SQL Server (specific) table not updating

I am having a really strange issue with classic asp insert/update that worked flawlessly for years and was never altered. Out of the blue, the table is no longer updating or taking new records. The code does not throw any errors and the SQL Server log shows no errors either. Other tables in the same database work fine so I can insert and update without issues.
Is there a way to find out what is happening with this table or whether it is locked for some reason. I restarted SQL Server and web application, even the server and no luck.
I updated the table directly in SQL Server and it updates and inserts new records fine.
I used the same code on another table and was able to update records.
Can someone please point me in the right direction as I am out ideas on what may be causing this.
Thanks in advance.
Here is the code:
<%
' *** Edit Operations: (Modified for File Upload) declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (UploadQueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(UploadQueryString)
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: (Modified for File Upload) set variables
If (CStr(UploadFormRequest("MM_insert")) = "update") Then
MM_editConnection = MM_ar_inventory_STRING
MM_editTable = "Artists"
MM_editRedirectUrl = "artists_add.asp?status=ok"
MM_fieldsStr = "ArtistName|value|WebsiteStatus|value|Biography|value|Notes|value|ImageFileName|value|ModifiedBy|value|DT|value|IpAddress|value"
MM_columnsStr = "ARTST_Artist|',none,''|ARTST_WebsiteStatus|',none,''|ARTST_Biography|',none,''|ARTST_Notes|',none,''|ARTST_ArtistImageFileName|',none,''|ARTST_ModifiedBy|',none,''|ARTST_LastModified|',none,NULL|ARTST_LastModifiedIP|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(UploadFormRequest(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And UploadQueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And UploadQueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & UploadQueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & UploadQueryString
End If
End If
End If
%>
<%
' *** Insert Record: (Modified for File Upload) construct a sql insert statement and execute it
Dim MM_tableValues
Dim MM_dbValues
If (CStr(UploadFormRequest("MM_insert")) <> "") Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
I notice that UploadQueryString is undefined so if you add this as the fist line
<%OPTION EXPLICIT%>
I guess that you will get some meaningful error messages
The craziest solution to the problem that totally seems unrelated was to disable Symantec Endpoint Protection (Network Protection) and it worked for a reason I cannot possibly explain! Thank you all for the suggestions above.

Cannot get inner content error

I'm in the process of migrating a website from one of my clients staging servers to a hosted server for one of their clients.
Everything else is working fine except the media gallery section of the website. When trying to open a gallery page I'm getting the error:
Cannot get inner content of ulGallerySlides because the contents are not literal.
I'm more of a techie than a programmer so I'm a bit stumped as to what is causing this and how to fix it. It works perfectly on the staging server.
The staging server is an IIS 7 server which I have full control over and the new server is hosted at an ISP on IIS 8 and I have very little control of it (just through WebSitePanel)
The code behind it is:
Public Sub BuildGalleryView()
Dim objDA As New clsDataAccess
Dim dtResults As New DataTable
Dim iCounter As Integer = 0
Dim intGalleryID As Integer = CInt(Request.QueryString("g"))
Dim strGalleryTitle As String = ""
Dim strGalleryDescription As String = "Test Gallery Description"
Dim strMediaTitle As String = "Test Media Title"
Dim strMediaDescription As String = "Test Media Description"
Dim strMediaURL As String = "./assets/images/placeholder.jpg"
dtResults = objDA.ODSGetGalleryMedia(intGalleryID).Tables(0)
'Set the gallery info first
strGalleryTitle = dtResults(0)("Gallery_Title").ToString
strGalleryDescription = dtResults(0)("Gallery_Description").ToString
lblGalleryTitle.InnerText = strGalleryTitle.ToString
lblGalleryDescription.InnerText = strGalleryDescription.ToString
lblGalleryMainTitle.InnerText = strGalleryTitle.ToString
If Not dtResults Is Nothing Then
'Loop through all the images and build the slider"
For i As Integer = 1 To dtResults.Rows.Count
strMediaTitle = dtResults(iCounter)("Media_Title").ToString
strMediaDescription = dtResults(iCounter)("Media_Description").ToString
strMediaURL = "./assets/" & dtResults(iCounter)("Media_URL").ToString
ulGallerySlides.InnerHtml = ulGallerySlides.InnerHtml & _
"<li>" & _
"<img src='" & strMediaURL & "' align='Slider'/>" & _
"<div class='flex-caption'>" & _
"<h2>" & strMediaTitle & "</h2>" & _
"<p>" & strMediaDescription & "</p>" & _
"</div>" & _
"</li>"
iCounter = iCounter + 1
Next
End If
End Sub
What do I need to change to fix this?

import from excel error in datagridview vb.net 2010

i am importing excel file in datagridview below is my code
'ofdImport.Filter = "Excel Files (*.xls)|*.xls"
ofdImport.FileName = ""
If ofdImport.ShowDialog(Me) = Windows.Forms.DialogResult.Cancel Then
Exit Sub
End If
txtPath.Text = ofdImport.FileName
If txtPath.Text <> "" Then
chkItemList.Visible = True
dgvImportData.Visible = True
pnlDataMsg.Visible = False
dgvImportData.Columns.Clear()
chkItemList.Items.Clear()
Try
Dim conExcel As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & txtPath.Text & " '; Extended Properties=Excel 8.0;")
Dim excelSelect As New OleDbCommand
Dim excelAdp As New OleDbDataAdapter
Dim excelSchemaDt As DataTable
Dim dset As New DataSet
If conExcel.State Then conExcel.Close()
conExcel.Open()
excelSelect.Connection = conExcel
excelSchemaDt = conExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing)
Dim sheetName As String = excelSchemaDt.Rows(0)("TABLE_NAME").ToString()
excelSelect.CommandText = "select * from [" & sheetName & "] "
excelAdp.SelectCommand = excelSelect
excelAdp.TableMappings.Add("Table", "TestTable")
excelAdp.Fill(dset)
dgvImportData.DataSource = dset.Tables(0)
Dim i As Integer
Dim q(dgvImportData.Columns.Count()) As String
For i = 0 To (dgvImportData.Columns.Count - 1)
q(i) = (dgvImportData.Columns(i).HeaderText.ToString())
Next i
conExcel.Close()
i = 0
Dim a As String = ""
'Dim q(frmImportWizard.gridImport.Columns.Count()) As String
For i = 0 To dgvImportData.Columns.Count - 1
a = dgvImportData.Columns(i).HeaderText.ToString()
'CheckedListBox1.Items.Add(a)
chkItemList.Items.Add(a)
Next i
chkAll.Visible = True
chkAll.Checked = False
lblColumnData.Visible = True
Catch ex As Exception
'MsgBox(ex.Message, MsgBoxStyle.Information)
End Try
End If
excel file contains phone nos for eg "9874532146/8456663225" in one colms and also i have "98455566966" in same colmns
the problem here is my code is not reading the phone numbers
without "/" its going blank in grid
please help
replaced connection string
Dim conExcel As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source='" & txtPath.Text & "';Extended Properties=""Excel 8.0;HDR=YES;IMEX=1""")