|
i work in project vb.net 2003 with sql server 2000 i make form to restore data base and i write this code
**********************************************
If File.Exists(Application.StartupPath & "\backup.txt") Then
Dim sreader As New StreamReader(Application.StartupPath & "\backup.txt")
Dim file_path As String
Dim fdialog As New OpenFileDialog
fdialog.Filter = "bak files (*.bak)|*.bak"
file_path = sreader.ReadToEnd
fdialog.InitialDirectory = file_path
If fdialog.ShowDialog = DialogResult.OK Then
file_path = fdialog.FileName
Dim sqlcom As New SqlCommand
sqlcom.Connection = CONN
sqlcom.CommandType = CommandType.Text
sqlcom.CommandText = "restore database ss from disk='" & file_path & "'"
Try
If CONN.State = ConnectionState.Open Then
CONN.Close()
End If
CONN.Open()
Me.Cursor = Cursors.WaitCursor
sqlcom.ExecuteNonQuery()
txtrestore.Text = file_path
Me.Cursor = Cursors.Default
Catch ex As Exception
MsgBox(ex.Message)
Me.Cursor = Cursors.Default
End Try
End If
End If
**********************************************
when i use this code an error occurred "database in use cannot restore it"
i need to stop used database so i can drop it and restore database
ma_refay
|
|
|
|
|
Dear All,
I am creating a Image Library and want to know what can the best and standard procedure to do this.
Concept is to have all the images needed by all projects (dlls and exes) in the product at a central place (in a single DLL) making it easy to distribute and maintain.
There are 2 ways of doing this.
1) Creating a new project, add all the images to it using "Add Existing Item" and set Build Action=Embeded Resource for each image.
OR
2) Creating a new project>Add new Item>Resources File and then adding all the images to it and setting Build Action=Embeded Resource for each image. Doing this will provide me a strongly typed DLL which will provide a property like access to all images. But .resx are mainly for localization. And here I am not localizing images.
My question is what is the standard way of doing this?
Do you guys know pros or cons of any of these methods?
Is anybody there knowing how Microsoft do it??? (When they need to create an image library)
Any links or articles for this?
Most important is, will the second (2) way will have any negative effect on start up time?
Regards,
----------------------------------------------------------------------------------
Jayvardhan Patil.
|
|
|
|
|
Hi Every Body
I asked before you about the way to export the DataSet into Excel Sheet, but I still have a problem in this subject...The code which I use is the following:
dim tblname as DataTable
Dim ExcelApp As Excel.Application = New Excel.Application
Dim Workbooks As Excel.Workbooks = ExcelApp.Workbooks
Dim Workbook As Excel.Workbook = Workbooks.Add(System.Reflection.Missing.Value)
Dim Sheets As Excel.Sheets = Workbook.Sheets
Dim Worksheet As Excel.Worksheet = Sheets("Sheet1")
Dim RowsCount As Integer = tblname.Rows.Count
Dim ColsCount As Integer = tblname.Columns.Count
Dim ColsCounter As Integer
Dim RowsCounter As Integer
'Columns Header
For ColsCounter = 0 To ColsCount - 1
Worksheet.Cells(1, ColsCounter + 1) = tblname.Columns(ColsCounter).ColumnName.ToString
'First Row for Columns Header
Next
For RowsCounter = 0 To RowsCount - 1
For ColsCounter = 0 To ColsCount - 1
Worksheet.Cells(RowsCounter + 2, ColsCounter + 1) = tblname.Rows(RowsCounter)(ColsCounter)
'Start With the Second Row Because First Row for Columns Header
Next
Next
ExcelApp.Visible = True
ExcelApp.UserControl = True
Note: After many searches over the Internet, I have found that the reason for the error in the previous code is named Late Binding, and I think that this is the main reason for the problem is what I said about the Late Binding. Is there any body know about this problem and the solution about it?
Simsem
|
|
|
|
|
You have not set the DataTable variable!
It should be something like:
Dim tblname As DataTable
tblname = MyDataSet.Tables("MyTable")
Then the rest of your code...
As it stands, the DataTable variable is empty.
Steve
|
|
|
|
|
The DataTable here is not empty because I am passing its value from another table using a query....so it is not empty
|
|
|
|
|
I don't see any kind of query in the code you posted...
You have just dimensioned your table and not assigned any data to it as far as I can see. Is there more code that you have not included?
Steve
|
|
|
|
|
The query exist in another form, I store the contents of the query in a DataTable and then pass this DataTable to my form where I display these data in a DataGrid and then I wanna Export these Data To Excel. So that be sure that there is a Data in the DataTable.
with Kind Regards.
your sincerely OBarahmeh
|
|
|
|
|
|
please help me with code which i can use to shutdown the application after 30mints, my application contains multi-forms and i want this code to be run when i click the start button on the second form "Form2".
Please note that i'm using the following code under the next or back buttons to switch between forms
< unload me
Form3.show >
as for example if i put timing code in Form2 , will this code stop when i click the next button which contains the code above?
Please advise and thank you for your help
Ali
|
|
|
|
|
Record the time when the user clicks on the "Start" button and start a timer (with a 1 minute interval) that will check the current time against the recorded one and close the application if 30 minutes have elapsed.
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
This is a very smart way , but how can i record the time from the system clock and what will be the data type for the variable which i will store the time in it to compare with the current type.
Please advise and thank you for your help.
Ali
|
|
|
|
|
Have a look at the System.DateTime class.
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Hi
This is the first time I am replying a query. All the Best!. Unless you unload the form that contains the Timer control you can keep count of the ticks.
In the timer control event you check for the period after which you want to close the application.
If it is visual basic, you can use this code,
Close All
End
If it is vb.net
Application.Exit
Hope this helps you.
Kanniah
|
|
|
|
|
hii all,
i have to devlop a vb.net application which works with pdf files.its a reader which upload pdf files and extract each page to JPEG format. but the core of the project depends on the "page turning effect(page flips over the reader while clicking Next/Previous button as in real magazine). i wuld like to add some graphics effect to the page flipping. i heard that ghostscript/postscript works with pdf files and these are providing graphics or curling effects to pdf pages. i want to deploy ghostscript/postsript code to vb.net application. Is It possible ? if yes, how ??
best regards
kannan
|
|
|
|
|
You can't use Ghostscript/Postscript in your VB.NET code. There is no component in the standard toolbox that understands those languages either. You'll need a 3rd party component that can render this stuff for you. I, unfortunately, don't know of any myself. You might want to try Googling for it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Please Help Me
How to avoid spelling mistek in text box (vb 6.0)
|
|
|
|
|
Implement a dictionary and check it after every keystroke ... be prepared to work hard
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Sinchan Nikam wrote: spelling mistek
Good luck to you.
|
|
|
|
|
Sinchan Nikam wrote: How to avoid spelling mistek in text box (vb 6.0)
Two ways to do it.
Purchase a third party libary.
use word to do it, this is a huge pain to do (not recommended really, it can be rather tedious).
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
Hello Sinchan,
ComponentOne has the VSSpell 8 control, which is an ActiveX control designed for use in VB6. It has both dictionary and thesaurus functionality, and has a utility to allow you to edit the existing or create new dictionaries and thesauruses. For more information, please visit http://www.componentone.com/products.aspx?TabTypeID=1&ItemType=1&PanelIndex=16&ItemID=54015&SubCategoryTypeID=0&TabMapID=92&TabID=111[^]. If you think that you may be interested, you can download a fully functional trial. The trial will have a sample application to show you how to use the control to spell check a textbox, among other text sources.
Suelinda W
Customer Engagement, ComponentOne LLC
|
|
|
|
|
Please Help Me !!!
How to check spelling mistek in perticular text box (vb 6.0)
-- modified at 3:21 Wednesday 30th August, 2006
|
|
|
|
|
Hi All, I am new to VB.net and I am struggling with small function I need to write. Basically this function must get results from two different datareaders, Oledb and SQL and compare the results.
Is using a datareader the right way of going about a comparison between two recordsets, or is there a better way. Basically I need to compare the results of the two recordsets and the differences must be noted in a file.
Any help will be appreciated.
Regards
Scorn.
|
|
|
|
|
Hi
You can go for Datasets, which is much easier to loop (as you can forward / rewind the dataset) you cannot do this in a datareader.
All the Best!
Kanniah
|
|
|
|
|
Hi Kanniah,
I am going to try Dave's solution first as I would like to save on resources. Should I not get it right I will try your solution.
Thanks for the reply.
Regards
Sean
|
|
|
|
|
You can do this with DataReaders. They'll be faster and more memory efficient than loading entire sets of data. They also offer the flexibility of looking at millions of records without loading them all into RAM.
After that, you just compare record for record, incrementing each DataReader to compare then next records.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|