|
Hi,
I have a problem updating a spreadsheet. I can read the info into a datagridview, but cant get it to update... actually I am not to sure how to update the spreadsheet. Can someone maybe help me, or direct me to some site that can be helpful.
Code for select/read:
<br />
Public Shared Function OpenSpreadsheet(ByVal strPath As String) As DataTable<br />
<br />
'Create new dataset to hold information<br />
Dim tableStatement As New DataTable()<br />
Dim column(1) As DataColumn<br />
<br />
Try<br />
'Connectionstring to the xls spreasheet on local/network drive<br />
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _<br />
"Data Source=" & strPath & ";" & _<br />
"Extended Properties=""Excel 8.0;"""<br />
<br />
'strConn..open()<br />
<br />
Dim daTimesheet As New OleDbDataAdapter("SELECT * FROM [Sheet1$B8:F30]", strConn)<br />
daTimesheet.Fill(tableStatement)<br />
<br />
<br />
tableStatement.PrimaryKey = New DataColumn() {tableStatement.Columns("projectID")}<br />
<br />
Catch Ex As Exception<br />
MessageBox.Show("Cannot fill Datatable. OpenSpreadsheet(): " & Ex.Message)<br />
<br />
Finally<br />
tableStatement.Dispose()<br />
'strConn.close()<br />
<br />
<br />
End Try<br />
<br />
Return tableStatement<br />
<br />
End Function<br />
Code for update:
<br />
Public Shared Function UpdateSpreadsheet(ByVal strPath As String) As DataTable<br />
<br />
Dim tableStatement As DataTable = New DataTable<br />
<br />
'Connectionstring to the xls spreasheet on local/network drive<br />
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _<br />
"Data Source=" & strPath & ";" & _<br />
"Extended Properties=""Excel 8.0;"""<br />
<br />
Try<br />
<br />
Using connection As New OleDbConnection(strPath)<br />
<br />
Dim adapter As New OleDbDataAdapter()<br />
adapter.SelectCommand = New OleDbCommand("SELECT * FROM [Sheet1$B8:F30]", connection)<br />
adapter.UpdateCommand = New OleDbCommand("UPDATE [Sheet1$B8:F30] SET FirstName= ?, LastName = ?", connection)<br />
<br />
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(adapter)<br />
<br />
connection.Open()<br />
<br />
adapter.Fill(tableStatement)<br />
<br />
tableStatement.PrimaryKey = New DataColumn() {tableStatement.Columns("projectID")}<br />
<br />
' Code to modify data in DataSet here <br />
<br />
adapter.Update(tableStatement)<br />
<br />
'Return 1<br />
Return tableStatement<br />
<br />
End Using<br />
<br />
Catch Ex As Exception<br />
MessageBox.Show("Cannot Update Datatable. UpdateSpreadsheet(): " & Ex.Message)<br />
'Dim strErrorUpdate As String = "Cannot Update Datatable. UpdateSpreadsheet(): " & Ex.Message<br />
<br />
'Return strErrorUpdate<br />
<br />
End Try<br />
<br />
End Function<br />
|
|
|
|
|
I am new to vb2005. I dun understand y do my DTPicker keep showing the calendar only. i have already set the formal to time but it only display the time but when i click the dropdown arrow it still show the caledar. Anyone knows how to change the calendar to time???
|
|
|
|
|
What do you expect it to show when dropped down?
|
|
|
|
|
I tot the DTPicker should show some default time for user to choose. i am confused as well? Cos i am doing the scheduler project require my user to choose the time for the shutdown to be perform. Wont the dropdown show some default selection which the user can select?
|
|
|
|
|
I'm calling a form with the show method, i would like to pass in a value from the calling form to the called form, to be used in form_load event.
How can I do this?
PJ
|
|
|
|
|
First you need to create the form before calling the Show() method.
Then you can pass the values either by creating parameters in the called form, or creating a function that receives parameter in the called form.
Another way is to create a new constructor of the form that accepts parameters.
"A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson
"Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin
Edbert
Sydney, Australia
|
|
|
|
|
Thanks for you help!
It's a bit wet here in Sydney
PJ
|
|
|
|
|
It's hailing in Hobart...
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
In the called form, you declaire a public shared variable like:
Public Shared myVar
In the calling form you will:
Dim mf as New CalledForm
mf.myVar = .....
mf.ShowDialog()
mf.Dispose()
Is this your need?
|
|
|
|
|
|
That's wrong. There is no need for the variable to be static ( shared ).
Also, it's much nicer to pass it through a constructor, although a public variable will work.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
if you want to run a EXE (Name : WW) from an other EXE (Name : QQ) with value sent to it you can use
sell "ww.exe value",vbnormalfocus
it is good and semble
soly
|
|
|
|
|
Hello
I am working with VB.Net, I want to read/write text data in remote server which is running on the same LAN.
I used the following code which gives an error
Imports System.IO
Imports System.IO.StreamReader
Dim path As String = "\\Server Name\Data\BarCode.txt"
Dim DirPath As String = "\\Server Name\Data"
Dim sw As StreamWriter
Dim di As DirectoryInfo
If Directory.Exists(DirPath) = False Then
di = Directory.CreateDirectory(“Data”)
End If
If File.Exists(path) = False Then
sw = File.CreateText(path)
sw.WriteLine("This is Test ")
sw.Flush()
sw.Close()
End if
How to make it working format?
Thanks
Muru
|
|
|
|
|
And that error is????
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
it through run time error. How to add user name, Password and Domain of the remote server?
|
|
|
|
|
If your machine and the remote machine are in the smae Windows domain, the code will use your security token to get into the remote machine. If your is seperate domains or in workgroup mode, you have to supply a username and password that the remote machine will recognize and has the appropriate rights to get at the network share you want on that server.
You can map a drive to that share then use it just like any normal drive letter. You can find and example here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi
Thanks for your quick reply. Actually my exact requirement is, I am running VB.Net mobile application for Windows CE.Net 4.2 OS. I want write log file on the Server which running on the same LAN. Will it possible to map drive in Window CE.Net 4.2? Or Is there any other way write data to the server file? Kindly please assist me
Thanks
Muru
|
|
|
|
|
I have no idea. I don't do mobile development. You probably should have added that major detail to your original post. Ask in the Mobile Development forum for a more qualified answer.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello,
I have a menu that a user can click and open a window. However, if the user was to click this form many time, it will continue to open up more windows. I want to prevent this from happening. If the user clicks open, it should just open the window once, if the window is already open, then it should get focus for that window.
I hope you understand, this is my code so far.
<br />
Dim rep10 As New NewCalls<br />
rep10.MdiParent = Me<br />
rep10.Show()<br />
Thanks in advance,
steve
|
|
|
|
|
http://www.codeproject.com/vb/net/Simple_Singleton_Forms.asp
|
|
|
|
|
Currently i doing a project on scheduler. My task is to perform a remote shutdown on the computers in my network at a specified time. I have problem figuring the code for this function. Can anyone help? Thanks a lot.
|
|
|
|
|
I am in the process of deploying a project using Visual Studio's Windows Installer but would like to check software activation keys before doing the install. I've looked at custom actions but they are executed after the installation. Is there a way to to this ?
Regards
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
You'll want to look at the Launch Conditions editor. This is where you can add requirements before an install.
|
|
|
|
|
I had a high school course in Visual Basic 6.0. However, I am now in college studying c++ in a unix-based environment. I am tryin to get back in to VB using VB.NET 2005. I am a gymnastics coach and i am trying to create a program that stores the skills each child has accomplished and retrieve them.
Any ideas as to how I can get the data to open and save?
|
|
|
|
|
j5matt wrote: ny ideas as to how I can get the data to open and save?
To be honest, VB2005 is so different to VB6, you really may find it easier to use C#, based on your knowledge of C++ style syntax ( although C# is nothing like C++ ).
Your best bet is probably an access database, only because it's more portable than a SQL Server one. Either way, there are tons of tutorials around on how to do this. Access also allows you to easily create your tables without writing any SQL.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|