|
i'm having an major performance issue with a concatination query i wrote against a datatable and was looking for a way to either speed up the query or a whole nother way of doing it which performs better...
at present my app spends 2 min processing this one loop, while i can do the two loops individually in about 5 seconds.
Here is the code:
<code>
For Each dr As DataRow In Main.DS_New.Tables(RightTable).Select(filter, "location,type desc")
Dim CATValues As String = Nothing
If dr.RowState <> DataRowState.Deleted And dr.RowState <> DataRowState.Detached Then
Select Case dr("name").ToString.ToLower
Case "value"
For Each DRsameLocation As DataRow In Main.DS_New.Tables(RightTable).Select(filter & " AND PK<>" & dr("PK") & " AND Location='" & dr("Location") & "' AND type='" & dr("type") & "' AND Name='" & dr("Name") & "'")
CATValues += Chr(215) & DRsameLocation("loc") & Chr(214) & DRsameLocation("value")
DRsameLocation.Delete()
Next
If CATValues = Nothing Then
dr("value") = dr("loc") & Chr(214) & dr("value")
Else
dr("value") = dr("loc") & Chr(214) & dr("value") & CATValues
dr("loc") = "MV"
End If
End Select
End If
Next
</code>
|
|
|
|
|
This would probably be better done on the database side with a stored procedure. Look into the COALESCE sql function.
|
|
|
|
|
unfortunatly since the data is in a datatable, and not in SQL, that is not an option.
|
|
|
|
|
Can someone tell me if I have to end up w/ my mail merge template open when creating a new document. I don't want to spend a lot of time trying to figure out how to close it, if it's not possible. Thanks!
|
|
|
|
|
|
any chance you can send me how you did the mail merge? i've been fighting with a way to get it to work where i process the mailmerge from a dataset...
|
|
|
|
|
Hello,
I have attached a VB program done in VB 2008 which adds annotations to an Acrobat PDF file specified by the user. So far, it works like a champ. However, my ultimate goal is to build a VB 2008 application that inserts metadata into the "Title", "Author", "Subject" and "Keywords" fields that are accessible from the Description tab of the Document Properties dialog box on the Acrobat "File" menu. I can do this in Acrobat's built-in JavaScript debugger just fine. For instance, the following will insert Harry Wishes into the author field.
this.info.author = "Harry Wishes"
My question: How do I invoke the Javascript object from Visual Basic 2008 that could access and modify this PDF metadata from Visual Basic? Help Apprectiated. Thanks!
Public Class Form1
Dim gApp As Acrobat.CAcroApp
<p>
Private Sub Form1_Load()
gApp = CreateObject("AcroExch.App")
End Sub
<p>
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pdDoc As Acrobat.CAcroPDDoc
Dim page As Acrobat.CAcroPDPage
Dim jso As Object
Dim path As String
Dim point(1) As Integer
Dim popupRect(3) As Integer
Dim pageRect As Object
Dim annot As Object
Dim props As Object
<p>
OpenFileDialog1.ShowDialog()
path = OpenFileDialog1.FileName
pdDoc = CreateObject("AcroExch.PDDoc")
If pdDoc.Open(path) Then
jso = pdDoc.GetJSObject
If Not jso Is Nothing Then
' Get size for page 0 and setup arrays
page = pdDoc.AcquirePage(0)
pageRect = page.GetSize
point(0) = 0
point(1) = pageRect.y
popupRect(0) = 0
popupRect(1) = pageRect.y - 100
popupRect(2) = 200
popupRect(3) = pageRect.y
' Create a new text annot
annot = jso.AddAnnot
props = annot.getProps
props.Type = "Text"
annot.setProps(props)
' Fill in a few fields
props = annot.getProps
props.page = 1
props.point = point
props.popupRect = popupRect
props.author = "Rob McAfee"
props.noteIcon = "Comment"
props.strokeColor = jso.Color.red
props.Contents = "I added this comment from Visual Basic!"
annot.setProps(props)
pdDoc.Close()
MsgBox("Annotation added to " & path)
Else
MsgBox("Failed to open " & path)
End If
End If
pdDoc = Nothing
End Sub
<p>
End Class</p></p></p></p>
|
|
|
|
|
That's going to be a function of the PDF Library you're using, if it's exposed at all. Without the documentation on that library, your next bet is to use the Object Browser window (F2 in Visual Studio) to explore the libraries object model, looking for some methods and/or properties that might do this for you.
|
|
|
|
|
Dear Sir,
I have a string object in vb.net 2005
like
Dim str as string
str=chr(14) & chr(27) & chr(72) & "My Name Is Bishu" & chr(20)
How I send it to printer through vb.net 2005 code
which print according to printer setting
massenger code
|
|
|
|
|
What you need is the ability to send raw data to the printer. This[^] is an example of what you're looking for.
|
|
|
|
|
how to capture hidden control and save in bmp format
|
|
|
|
|
You have to sit down between the shrubs besides the road your application, trying to avoid noises so you don't scare it off. Then, when the control emerges from its hideout, hit it hard with a club on its head, but avoid injuring it too bad, then put it into your bmp-format, which you hopefully brought along with you in a suitable size.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
you cant work with screen shot
this code will work out for coz this code will take control as bitmap
so if its works tell me if not i'll give some other suggesstion
manavharsh@yahoo.com my mail id
there is one more option to print the control also
its an vb.net code with vb
Imports System.Drawing.Printing
Imports System.Drawing.Imaging
Public Class Form1
Private m_PrintBitmap As Bitmap
Private WithEvents m_PrintDocument As PrintDocument
Private Declare Auto Function BitBlt Lib "gdi32.dll" (ByVal hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As System.Int32) As Boolean
Private Const SRCCOPY As Integer = &HCC0020
Private Function GetFormImage() As Bitmap
' Get this form's Graphics object.
Dim me_gr As Graphics = Me.CreateGraphics
' Make a Bitmap to hold the image.
Dim bm As New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height, me_gr)
Dim bm_gr As Graphics = me_gr.FromImage(bm)
Dim bm_hdc As IntPtr = bm_gr.GetHdc
' Get the form's hDC. We must do this after
' creating the new Bitmap, which uses me_gr.
Dim me_hdc As IntPtr = me_gr.GetHdc
' BitBlt the form's image onto the Bitmap.
BitBlt(bm_hdc, 0, 0, Me.ClientSize.Width, Me.ClientSize.Height, _
me_hdc, 0, 0, SRCCOPY)
me_gr.ReleaseHdc(me_hdc)
bm_gr.ReleaseHdc(bm_hdc)
' Return the result.
Return bm
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnprint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprint.Click
m_PrintBitmap = GetFormImage()
' Make a PrintDocument and print.
m_PrintDocument = New PrintDocument
m_PrintDocument.DefaultPageSettings.Landscape = True
m_PrintDocument.Print()
End Sub
Private Sub m_PrintDocument_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles m_PrintDocument.PrintPage
' Draw the image centered.
Dim x As Integer = e.MarginBounds.X + _
(e.MarginBounds.Width - m_PrintBitmap.Width) \ 2
Dim y As Integer = e.MarginBounds.Y + _
(e.MarginBounds.Height - m_PrintBitmap.Height) \ 2
e.Graphics.DrawImage(m_PrintBitmap, x, y)
' There's only one page.
e.HasMorePages = False
End Sub
End Class
|
|
|
|
|
Just wondering, if I have an app.config file with a range of values including:
<add key="DeleteEmails" value="no">
If this entry is deleted from the config file, what will be returned if I try to read from it in my program?
|
|
|
|
|
It will crash, you need to write code that catches this exception and returns a default.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
I am making an appliaction where i need to open a file and save it in different place.
Now the file type is .doc, so i need to open the file in MS Word (Its a stand alone application and user may use MS Word 2003 or 2007), with in the application or out side the application, till now i am comfortable to do. The problem raises when its time to save the application.
When i am trying to save it through MS Word, it actually show the save dialog box. Which has to be blocked as i need to save the file only at one particular location, through code.
Can any one tell me how to block Save button (New and Open are always bloked by default) (OR) block Standard tool bar in MS Word. And to block Menu bar in MS Word.
Any help would be greet...
It very urgent please help me...
Jats
|
|
|
|
|
Hi can you post the code you're using to save the file. I might be able to help with that.
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
Here is the code to save the contents in a different file...
Here is the code, Add reference to Microsoft Word 11.0 Library
<br />
Imports Microsoft.Office.Interop.Word<br />
Imports System.Data<br />
Imports System.Data.OleDb<br />
Imports System.Data.SqlClient<br />
Imports System.Configuration<br />
<br />
<br />
Public Class form1<br />
Dim WithEvents wordApp As New Microsoft.Office.Interop.Word.Application<br />
Dim WithEvents doc As New Microsoft.Office.Interop.Word.Document<br />
Dim strSaveFile As String = "C:\Test\Retrive_the_data.doc"<br />
<br />
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
'Create a Word App<br />
<br />
wordApp.Visible = False<br />
<br />
With wordApp<br />
.Documents.Open(strSaveFile)<br />
'Clipboard.SetText("lpt ", TextDataFormat.Text)<br />
'wordApp.Selection.InsertParagraph()<br />
'wordApp.Selection.Paste()<br />
<br />
Dim strsaveasfile As String = "c:\Test\retry.doc"<br />
Try<br />
If (strSaveFile <> String.Empty) And (Not (IsNothing(strSaveFile))) Then<br />
.ActiveDocument.SaveAs(strSaveFile)<br />
.ActiveDocument.SaveAs(strsaveasfile)<br />
End If<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
End Try<br />
<br />
.Visible = True<br />
.Activate()<br />
End With<br />
<br />
System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp)<br />
End Sub<br />
<br />
End Class<br />
Now i just have to deactivate the Save as button in MS Word.
And if it is possible i would also like to block Title bar and Menu bar.
Jats
modified on Friday, April 18, 2008 8:23 AM
|
|
|
|
|
I see what you're trying to do. As far as I know what you're trying to do is pretty impossible. But what you can do is that you can change read only property.
With wordApp
.Documents.Open(strSaveFile, , <font color="blue">True</font>)
That parameter makes your document READ ONLY, but you cannot block save box.
By looking at code, it seems like you want something that user can only read but not change right? If this is a case then why not convert your doc to PDF and then show that!! They wont be able to do anything.
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
Actually thats not what i want to do.
The operation i want to perform is to open a document from a location say 'loc1' and after making the changes save it to 'loc2' but both locations have to be handled by Application I cannot allow user to save it in another location as if it is done I cannot track the documents for generating final report combining all the docs.
So what i am actually doing is i am taking the input file (doc1) from loc1 and saving it as doc2 in loc2.
And then oppening doc2 from loc2 so that user can make changes and click save. and it just updates the present document that is... Doc2 in Loc2.
Thats all...
But in case the user makes save as operation then it will lead to problem while generating reports...
Basically Doc1 and soon in Loc1 are templates and Doc2 and soon in Loc2 are mofiled files related to a particular project.
Jats
|
|
|
|
|
Hi,
I want to know how can we hash the password that we have got from user to save in database(SQL server) ? I want the exact code that I must write !
I formerly in ASP 2003 use this code:
<br />
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5")<br />
but in VB 2005 I don't know how I can do it.
please help. tanx !
|
|
|
|
|
That method is still available.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
You're better off not using System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile as you'll have to include the System.Web reference in you're project. Try using the SHA1 hash algorithm instead:
<br />
Imports System.Security.Cryptography<br />
Imports System.Text<br />
<br />
Public Shared Function GeneratePasswordHash(ByVal password As String) As String<br />
Dim pwdData As Byte() = Encoding.UTF8.GetBytes(password)<br />
Dim sha As SHA1 = New SHA1Managed<br />
<br />
Dim hashData As Byte() = sha.ComputeHash(pwdData)<br />
sha.Clear()<br />
<br />
Return Convert.ToBase64String(hashData)<br />
Return Encoding.UTF8.GetString(hashData)<br />
<br />
End Function<br />
modified on Saturday, April 19, 2008 5:30 AM
|
|
|
|
|
Thank U so much Rob Smiley.
I try that.
|
|
|
|