|
Hello,
I have just had a error deploying a clickonce application. The error is below and has been solved
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {10020200-E260-11CF-AE68-00AA004A34D5} failed due to the following error: 80040154.
The above problem caused me hours to solve. However, was solved my simply by doing the following: regsvr32 sqldmo.dll. to register the dll on the client machine.
I have created a deployment using the MSI, and never had this problem. But clickOnce does cause this problem if the dll does not exist and is not registered on the client machine.
Is there any way that you can use clickone to add this dll on the client's machine, so I don't have to go to trouble of registering manually.
When I publish this file I have added all the required dlls.
This is what I have done:
1. In the solution explorer | references | properties | set the sqldmo local copy to true
2. On the publish tab | Application File | set the publish status for the sqldmo.dll to include and required
3. Prereqisities | Added the .net framework, CR Reports .Net, MS Data Access components.
VB 2005 & SQL Server 2005.
Many thanks for any help,
Steve
|
|
|
|
|
I need to highlight the an item in the list box, here is the code:
If MyCameraSchedules.Length = 1 Then
lstScheduleNames.SelectedIndex = 0
Else
lstScheduleNames.SelectedIndex = MyCameraSchedules.Length - 1
End If
So basically if I have more than 1 schedule, I want to highlight the last schedule in the list box, if only 1 then highlight the first item which is index 0. However, I get an Exception complaining object reference not set to an instance of object.
I also refresh() the listbox, but doesn't help.
Anyone?
Waiting
|
|
|
|
|
Given the code you gave, the only thing that would be not set to an instance would be the MyCameraSchedules and not the listbox. Have you verified that MyCameraSchedules is set?
|
|
|
|
|
It should be as simple as this:
If MyCameraSchedules.Length > 0 And lstScheduleName.Items.Count >= MyCameraSchedules.Length Then
lstScheduleNames.SelectedItem = lstScheduleNames.Items.Count - 1
End If
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks, but for some odd reason that still doesn't highlight the item if there is only one item in the list box.
If there are more items, then it always highlights the first item.
What I need to do is highlight the first item if only item, otherwise highlight the last.
Thanks b4 hand
Yoshimitsu
|
|
|
|
|
Thanks Dave, This solved the problem
If MyCameraSchedules.Length = 1 Then
lstScheduleNames.SelectedIndex = lstScheduleNames.Items.Count - 1
Else
lstScheduleNames.SelectedIndex = MyCameraSchedules.Length - 1
End If
Yoshimitsu
|
|
|
|
|
I have been trying to write data from a windows app to an Excel file (I have tried creating a new file and appending an existing one).
The web provided me with an abundance of different ways to access an Excel file, but all of these methods are either outdated (.NET claims "old format or invalid type library"), require the use of rather complicated ASP.NET code, or use xml conversion (which example code was also partly outdated).
In the end all I managed was creating a text file with the data, tab, and enter characters, and saving it as an Excel file. This method is extremely clumsy, because I have to count how many tabs and enters I need to write, to be able to determine where any piece of data ends up on the sheet, not to mention that any form of formatting is impossible. And in the end Excel still needs to "import" the file.
I have trouble believing that I am the only one who needs to export data to Excel from windows apps.
can anybody please put me on the right track?
Thanks,
Johan hakkesteegt
|
|
|
|
|
Hi Johan,
I Frequently have to move data from VB.NET to excel, I find using Excels XML ability extremely useful because you just have to flush tags to a file, and name it .xml of .xls and it will open in Excel perfectly. Excel in XML also gives you full control of formatting and data typing. My Advice to you is to create an excel file with the formatting you wish to use, and then save it as type .XML Then open the file in word or even visual studio and examine the tags. Copy the headers and footers, then write some code to flush the content tags out. If you would like to see some examplse I have a few general purpose vb functions that I could send you.
|
|
|
|
|
Hi Kevin,
If you could provide me with some example code, I would be very greatfull, especially if it contains something about placement of data and the actual saving it back to an excel file (that can be opened by a regular user). Ofcourse general purpose functions are always appreciated!
Johan
|
|
|
|
|
Here is a simple app that takes a dataset and writes a worksheet per data table in the set
Public Sub writeToExcel(ByVal source As DataSet)
Dim doc As New System.IO.StreamWriter("Excel.xls") 'use .xls even though its an xml file
Dim startExcelXML As String = ""
startExcelXML &= "<xml version>"
startExcelXML &= vbNewLine & "<Workbook " + "xmlns=""urn:schemas-microsoft-com:office:spreadsheet"""
startExcelXML &= vbNewLine & Microsoft.VisualBasic.Chr(10) & "" + " xmlns =""urn:schemas-microsoft-com:office:office"""
startExcelXML &= vbNewLine & "xmlns:x=""urn:schemas- microsoft-com:office:" + "excel"""
startExcelXML &= vbNewLine & "xmlns:ss=""urn:schemas-microsoft-com:" + "office:spreadsheet"">"
'write the styles tags that format the data and cells properly
startExcelXML &= vbNewLine & "<Styles>"
startExcelXML &= vbNewLine & " <Style ss:ID=""Default"" ss:Name=""Normal"">"
startExcelXML &= vbNewLine & " <Alignment ss:Vertical=""Bottom""/>"
startExcelXML &= vbNewLine & " <Borders/>"
startExcelXML &= vbNewLine & " <Font/>"
startExcelXML &= vbNewLine & " <Interior/>"
startExcelXML &= vbNewLine & " <NumberFormat/>"
startExcelXML &= vbNewLine & " <Protection/>"
startExcelXML &= vbNewLine & " </Style>"
startExcelXML &= vbNewLine & "<Style ss:ID=""ColHeader"">"
startExcelXML &= vbNewLine & "<Alignment ss:Horizontal=""Center"" ss:Vertical=""Bottom""/>"
startExcelXML &= vbNewLine & "<Font x:Family=""Swiss"" ss:Size=""8"" ss:Bold=""1""/>"
startExcelXML &= vbNewLine & "<Interior ss:Color=""#C0C0C0"" ss:Pattern=""Solid""/>"
startExcelXML &= vbNewLine & "</Style>"
startExcelXML &= vbNewLine & " <Style ss:ID=""Reg"">"
startExcelXML &= vbNewLine & " <Font " + "x:Family=""Swiss"" ss:Bold""0""/>"
startExcelXML &= vbNewLine & " </Style>"
startExcelXML &= vbNewLine & "</Styles>"
'write the header to the file
doc.WriteLine(startExcelXML)
'write one sheet per table
For Each tab As DataTable In source.Tables
Dim sheetname As String = "<Worksheet ss:Name="
sheetname &= Microsoft.VisualBasic.Chr(34)
sheetname &= tab.TableName.Trim
sheetname &= Microsoft.VisualBasic.Chr(34)
sheetname &= ">"
doc.WriteLine(sheetname)
doc.WriteLine("<Table>")
'write the column headers
doc.WriteLine("<Row>")
For Each col As DataColumn In tab.Columns
doc.Write("<Cell ss:StyleID=""ColHeader""><Data ss:Type=""String"">")
doc.Write(col.ColumnName)
doc.WriteLine("</Data></Cell>")
Next
doc.WriteLine("</Row>")
'write the table
For Each row As DataRow In tab.Rows
doc.WriteLine("<Row>")
'Dim i As Integer
For i As Integer = 0 To tab.Columns.Count - 1
doc.Write("<Cell ss:StyleID=""Reg""><Data ss:Type=""String"">")
doc.Write(row.Item(i))
doc.WriteLine("</Data></Cell>")
Next
doc.WriteLine("</Row>")
Next
doc.WriteLine("</Table>")
doc.WriteLine("</Worksheet>")
Next
doc.WriteLine("</Workbook>")
doc.Close()
End Sub
this can be opened in excel. You will have to add your own formating to make the sheet look like you want, to do that just make changes, save it and open it and see what it did to the tags. Then make your code do the same.
Hope this helps
Kevin
|
|
|
|
|
Hi Kevin,
You are a life saver!
Johan
|
|
|
|
|
Don't Mention it, I spent at least a week a few months back searching for the same thing, I hope it all works out for you.
Kevin
|
|
|
|
|
Hi,
I have created a crytal report using TTX file and i am trying to connect ADO recodset to the report.
When crpReport.Preview of the following code is executed,I am getting the runtime error like "runtime error '20527' sql server error"
Please help me to solve this.
Dim crpApplication As CRPEAuto.Application
Dim crpReport As CRPEAuto.Report
Dim crpDatabase As CRPEAuto.Database
Dim crpTables As CRPEAuto.DatabaseTables
Dim crpTable As CRPEAuto.DatabaseTable
Set crpApplication = CreateObject("crystal.crpe.application")
Set crpReport = crpApplication.OpenReport(App.Path & "\Report1.rpt")
Set crpDatabase = crpReport.Database
Set crpTables = crpDatabase.Tables
Set crpTable = crpTables.Item(1)
Call crpTable.SetPrivateData(3, adoRs)
crpReport.Preview
Environment: Visual Basi 6, Crytal Report 6, Sybase
Thanks
Ramesh
|
|
|
|
|
hey guys
Im reading from a file using the following code :
Do While Not sr.Peek = -1 'end of file<br />
checkStr = sr.ReadLine<br />
If checkStr.Contains(Chr(34)) Then<br />
....<br />
else if checkstr.contains("123") Then<br />
....<br />
end if
the thing that i m asking .how can i transform the If/else statment to select case statement...
means :
is it feasible with<br />
select case checkstr<br />
case checkstr.contains(ch(34))<br />
.....<br />
case checkstr.contains("123")<br />
.....<br />
end case
Regards
Ramy
|
|
|
|
|
Select Case True
Case checkstr.contains(ch(34))
MsgBox(2)
Case checkstr.contains("123")
MsgBox(1)
Case Else
MsgBox(0)
End Select
|
|
|
|
|
'Select Case checkStr
'Case = (Chr(34))
'
'Case = "123"
'
'Case Else
'
'End Select
-------------------------
Check above post for right answer
-------------------------
-- modified at 10:45 Thursday 16th November, 2006
|
|
|
|
|
Yone,
Wouldn't that look for an exact match instead of searching the string for those characters?
Nathan
|
|
|
|
|
Wow, how dumb of me. (i guess i should stop surfing the web in bed)
Thanks a million for correcting me.
|
|
|
|
|
i have to check for a particular condition, and if the user doesnt satisfy that condition, i need to logoff him forcibly. (OS: WindowsXP and Win2K)
obviously i have to use a windows service, but i couldnt figure out the code to loghim off.
can anyone please help
|
|
|
|
|
Though it doesn't force a logoff the code below will programatically lock the workstation using an API call
Declare Function LockWorkStation Lib "user32.dll" () As Long
Call LockWorkStation() after condition evaluation.
I'll look around for a better example.
|
|
|
|
|
Here is an API call that forces a logoff BUT I'm still trying to work out a bug - it throws an exception during debug saying that I've unbalanced the stack, though this exception isn't thrown when I run the code from outside the IDE.
So basically what I'm saying is that the code below ain't perfect but it's closer to what you asked for than the previous example.
This function takes two arguments. First argument is one or more flags (the declared constants) instructing windows how to shutdown. Second argument is reserved (I don't know why yet), and is set to zero.
Public Const EWX_LOGOFF = 0
Public Const EWX_SHUTDOWN = 1
Public Const EWX_REBOOT = 2
Public Const EWX_FORCE = 4
Declare Function ExitWindowsEx Lib "user32" Alias _
"ExitWindowsEx" (ByVal uFlags As Long, ByVal dwReserved _
As Long) As Long
then when needed call
ExitWindowsEx(EWX_FORCE Or EWX_LOGOFF, 0)
I'm still trying to figure it out better. Sorry that the help I've provided isn't very informative or perfect.
|
|
|
|
|
You've unbalanced the stack because your using the wrong data types for the parameters and return values. I'll make an educated guess and say that you lifted some VB6 code and tried to use it under VB.NET without any modification.
Under VB6, the Long type is a 32-bit signed integer, while under VB.NET, the Long type is a 64-bit signed integer. This is why the stack is unbalanced. If you're going to use VB6 code, you have to change all the Long's to Integers under VB.NET:
Public Const EWX_LOGOFF As Integer = &H0
Public Const EWX_POWEROFF As Integer = &H8
Public Const EWX_REBOOT As Integer = &H2
Public Const EWX_RESTARTAPPS As Integer = &H40
Public Const EWX_SHUTDOWN As Integer = &H1
Public Const EWX_FORCE As Integer = &H4
Public Const EWX_FORCEIFHUNG As Integer = &H10
Declare Function ExitWindowsEx Lib "user32" _
(ByVal uFlags As Integer, ByVal dwReserved As Integer) As Integer
Oh! You also don't need the 'Alias' clause if the name you gave the function matches the name in the library.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
"Wow" looks neat, you got my 5
|
|
|
|
|
Thanks for corrections, I seldom have need to use API calls.
Dave Kreskowiak wrote: I'll make an educated guess and say that you lifted some VB6 code
Close - API Viewer 2004
Dave Kreskowiak wrote: Under VB6, the Long type is a 32-bit signed integer, while under VB.NET, the Long type is a 64-bit signed integer.
I thought Long was Long regardless, my mistake
Great advice, thanks!
|
|
|
|
|
Dear friends,
thanks for the timely help.
|
|
|
|