|
thanks. but that codings is allow to SaveAs the file to another location..
actually wat i want na... that pdf viewer is not give access to do saveAs, Print, etc .......only to view the pdf file..
thanks..
|
|
|
|
|
..that means that there's a physical file, doesn't it. What's to stop me from opening that file using Acrobat?
Bastard Programmer from Hell
|
|
|
|
|
Adobe reader is give the permission to SaveAs & print.. but i need to view the pdf file without the option SAVEAS & Print...
|
|
|
|
|
So? I'll simply download CutePDF to print the file.
If the file is on the computer of the user, then the user becomes the owner of that file. You can't prevent the owner from manipulating his/her files.
Bastard Programmer from Hell
|
|
|
|
|
I'm converting an old VB6 application to VB2010 and I've run across a situation I can't seem to figure out from the books I have and web posts so your help will be appreciated.
The problem is iterating through a recordset assigning values to 20+ fields and then doing an update batch.
So far all I've been able to figure out is to use an OleDBCommand class and ExecuteNonQuery method and create individual UPDATE SQL commands for each of the 20+ fields I'm dealing with. I'm hoping there is a simpler way similar to the old ADO UpdateBatch.
Here's sort of what my old VB6 code looks like:
Set Conn = New ADODB.Connection
Conn.Open strDSNName
Set rs = New ADODB.Recordset
gstrSQL = "SELECT * from Judges;"
Set rs.ActiveConnection = Conn
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.LockType = adLockBatchOptimistic
rs.Open strSQL
Conn.Close
Set Conn = Nothing
rs.MoveFirst
Do Until rs.EOF
rs.Fields("Response3").Value = rs.Fields("Response2").Value
rs.Fields("AssignedCat3").Value = rs.Fields("AssignedCat2").Value
...
20 more lines setting field3 to field2
...
rs.MoveNext
Loop
Set Conn = New ADODB.Connection
Conn.Open strDSNName
rs.ActiveConnection = Conn
rs.UpdateBatch
rs.close
set rs = nothing
conn.close
set conn.close
Thanks
|
|
|
|
|
MSDN[^] has a page on the topic.
Bastard Programmer from Hell
|
|
|
|
|
Thank you for taking the time to point me in this direction. I have been looking at the dataadapter. Unfortunately (for me), having never seen a VB snippet that applies to my situation I'm sort of lost, especially since I have never used "Parameters" in an update statement. It is sometimes difficult for me to understand a concept without a real life example.
Thanks (still hoping for a code sample from someone that sort of addesses my VB6 snip)
|
|
|
|
|
Member 8605177 wrote: still hoping for a code sample
Also on MSDN, using a DataTable [^]
Bastard Programmer from Hell
|
|
|
|
|
since I've never users parameters i have a question - assume my table consists of 20 fields. does that mean I need to define 20 parameters, one for each field?
|
|
|
|
|
Yup.
Bastard Programmer from Hell
|
|
|
|
|
Is there any workarounds on how to read the data from sql join using sqldatareader.
query ="SELECT TABLE1.FID FROM TABLE2 WHERE TABLE1.ID = TABLE2.ID"
Dim sqlRead As SqlDataReader
cmd.CommandType = CommandType.StoredProcedure
sqlRead = cmd.ExecuteReader
While sqlRead .Read()
Dim str as String = sqlRead("FID")
End While
Yes, I know that the good solution is to put "AS" clause on query.
Let say, TABLE1.FID AS FID.
But the problem is I have 100 StoredProcedures and each has no alias.
It's very difficult if I will modify all the SP just to put that clause.
Thanks in advance
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
You can retrieve datareader results by using the index, like this:-
While dr.Read
Dim id As String = dr(0).ToString()
id = dr.GetString(0)
id = dr.GetInt32(0)
id = dr.GetDateTime(0)
id = dr.GetDecimal(0)
End While
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
thank you for quick reply.
i found out also that if i will not put dr.read in an if statement, it causes an error. weird.
like this...
if dr.read then
while....
endif
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
I would change your
if dr.read then
to
if dr.hasrows then
This is a check to see if the datareader has any rows in its collection. further reading Datareader.hasrows[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
how can i read the datareader backward.
let say i have data
number=1,2,3,4,5,6,7,8,9,10.
dr(number)
in dataset,
ds.Tables(0).Rows.Count - 1 To 0 Step -1
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
You can't read a datareader backward as it is a forward only reader. You will have to do an order by on your sql query to return the rows in the order you wish them. i.e
SELECT id, name FROM employees ORDER BY id DESC or something like that.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Hi,
Wayne's suggestion is viable, but using index numbers instead of field names is not recommended, because your code will become harder and harder to maintain, when you add more fields to your query.
Generally speaking you may want to adapt your code thus:
If sqlRead.HasRows Then
Dim str as String = String.Empty
Do While sqlRead.Read()
str = sqlRead.Item("FID").ToString
End While
End If
If your query has only a single field with the name FID, the DataReader will automatically translate FID to TABLE1.FID.
Just as a matter of interest, are you using MS SQL or some other DB, because I can't get your query to work? In other words, what I am wondering is, the problem may simply be the query, and not so much the code.
Cheers,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Ummm, If query is actual code in your app, it is not a stored procedure. That's straight up CommandType.Text . A stored procedure in your code would be the name of a stored proc in the database itself.
|
|
|
|
|
how to get connection string in vb.net.....???
i made database from vb.net itself
n copy connection string but i doesn't work....
can one help me in my problem
i used dis code....
Dim ConnectionString As String = "Data Source=|DataDirectory|\Database1.sdf"
//above codes gives some error
Dim Connection As New SqlConnection(ConnectionString)
Dim command As New SqlCommand("SELECT * FROM student", Connection)
Try
Connection.Open()
command.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
Finally
Connection.Close()
End Try
|
|
|
|
|
Have a look at www.connectionstrings.com[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
1) You cannot copy a connectionstring and "hope" that it works. It won't.
2) You are reading a SqlCE database (a local file-based db), and using the SqlClient-objects (SqlConnection, SqlCommand) - that will not work. They are meant for use with Sql Server. SqlCe has it's own[^].
3) ExecuteNonQuery will never show results, only the number of rows that were affected.
Can you check the file-extension of your physical database-file? If you can tell us what type of database you're using, we could provide the correct access-code.
Bastard Programmer from Hell
|
|
|
|
|
Hi guys
I want to copy Content from Word Document (2007 or 2010) . and I am Using File Stream to do this action.
here is the Code
=====================================================
Dim strPath As String = "C:\Users\Toshiba\Desktop\Test.docx"
Dim fStream As New FileStream(strPath.ToString, FileMode.Open, FileAccess.Read)
Dim sReader = New StreamReader(fStream)
sReader.BaseStream.Seek(0, SeekOrigin.Begin)
While sReader.Peek() > 0
RichTextBox1.Text += sReader.ReadLine()
End While
sReader.Close()
====================================================
I don't no when I copy the Content to RichBox it copy garbage data ..
But when i copy from txt file it works fine with out any mistake .
But i need to copy from word document (2007 or 2010) because my User request is this .
so can any modified my code to copy from word without garbage data ..
i try to modify by set this
----------------------------------------
Dim sReader = New StreamReader(fStream, System.Text.Encoding.Unicode)
----------------------------------------
but no change on the result..
so am waiting your replays either by edit the above code or give my easiest way to do this action ..
thanks in advance
|
|
|
|
|
You cannot use a FileStream to read a Word document, as these files are not just text files but compressed xml files. To interact with Word documents, you need to use the Office Interop assemblies. Here[^] is a good place to start {MSDN).
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Hi.
I need a help with showing/hiding rows in datagridview by setting the trackbar value. The below example works if there are not too much rows. If there are greater number of rows then after you change a value of trackbar you must wait for a few seconds for the datagridview to redraw and only then you can use trackbar again...
Apparently I must use multithreading to achieve what I want: when I use trackbar, datagridview starts to redraw, but if I use trackbar again before datagridview finishes redrawing, it immediately stops redrawing according to previous trackbar value and starts to redraw from the beginning according to current trackbar value. That way trackbar will never be frozzen (stuck, unusable...).
I tried with backgroundworker but got error "Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on." - Maybe didn't use it right?
P.S. I have old and slow computer. If you have new and fast computer maybe you wont experience what I'm describing here so try to increase number of added rows in line 'For i As Integer = 1 To 5000' (I added 5000 rows here) - and if you have even older and slower computer than you will have to decrease this value or you will have to wait to long after you drag the thumb in trackbar.
Public Class Form1
WithEvents trackbar1 As New TrackBar
WithEvents DataGridView1 As New DataGridView
Dim label1 As New Label
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Controls.Add(trackbar1)
trackbar1.Location = New Point(0, 150)
trackbar1.Size = New Size(220, 140)
trackbar1.Maximum = 40
trackbar1.LargeChange = 1
trackbar1.SmallChange = 1
AddHandler trackbar1.Scroll, AddressOf TrackBar1_ScrollHandler
Me.Controls.Add(label1)
label1.Location = New Point(0, 200)
label1.Size = New Size(220, 140)
label1.Text = "Only rows with values in Column2 greater than 0 are visible"
Me.Controls.Add(DataGridView1)
DataGridView1.Location = New Point(0, 0)
DataGridView1.Size = New Size(220, 140)
DataGridView1.AllowUserToAddRows = False
DataGridView1.RowHeadersVisible = False
DataGridView1.TabIndex = 1
Dim column1 = New DataGridViewTextBoxColumn()
column1.Name = "Column 1"
column1.ValueType = GetType(System.DateTime)
column1.ReadOnly = True
DataGridView1.Columns.Add(column1)
Dim column2 = New DataGridViewTextBoxColumn()
column2.Name = "Column 2"
column2.ValueType = GetType(System.Int64)
column2.ReadOnly = True
DataGridView1.Columns.Add(column2)
Dim rnd1 As New Random
For i As Integer = 1 To 5000
DataGridView1.Rows.Add(DateSerial(2011, rnd1.Next(1, 12), rnd1.Next(1, 28)), rnd1.Next(0, 40))
Next
End Sub
Private Sub TrackBar1_ScrollHandler(sender As System.Object, e As System.EventArgs)
For i As Long = 0 To (DataGridView1.Rows.Count - 1)
If DataGridView1.Rows(i).Cells("Column 2").Value < trackbar1.Value Then
DataGridView1.Rows(i).Visible = False
Else
DataGridView1.Rows(i).Visible = True
End If
Next
label1.Text = "Only rows with values in Column2 greater than " + trackbar1.Value.ToString + " are visible"
End Sub
End Class
|
|
|
|
|
Hi,
I would change two things:
1. prevent the DGV from redrawing itself while you are changing the row visibilities.
2. Improve the speed of the trackbar loop.
So it might end up looking somewhat along these lines:
Private Sub TrackBar1_ScrollHandler(sender As System.Object, e As System.EventArgs)
Dim minval as int = trackbar1.Value
DataGridView1.SuspendLayout
For Each row as DataGridViewRow in DataGridView1.Rows
row.Visible = row.Cells("Column 2").Value >= minval
Next
DataGridView1.ResumeLayout
label1.Text = "Only rows ... " + trackbar1.Value.ToString + " are visible"
End Sub
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
modified 2-Feb-12 21:40pm.
|
|
|
|