Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Excel UPDATE statement doesn't write to the Excel File

Reply
Thread Tools

Excel UPDATE statement doesn't write to the Excel File

 
 
RnkG RnkG is offline
Junior Member
Join Date: Dec 2008
Posts: 1
 
      12-22-2008
Private strUpdate As String = "UPDATE [Sheet1$] SET
ItemDescription='@Item', Source='@Source', Customer='@Cust',
Address='@Address', City='@City', State='@State', Zip='@Zip', Processed='@Processed', Used='@Used', Store='@Store' WHERE TagNumber='@TagNum'"

Function updateExcel() As Boolean
oleCmdWrite = New OleDbCommand
oleCmdWrite.CommandText = strUpdate
oleCmdWrite.Connection = oleConn
olePram = oleCmdWrite.Parameters.Add("@TagNum", OleDbType.VarChar)
olePram.SourceColumn = "TagNumber"
olePram = oleCmdWrite.Parameters.Add("@Item", OleDbType.VarChar)
olePram.SourceColumn = "ItemDescription"
olePram = oleCmdWrite.Parameters.Add("@Source", OleDbType.VarChar)
olePram.SourceColumn = "Source"
olePram = oleCmdWrite.Parameters.Add("@Cust", OleDbType.VarChar)
olePram.SourceColumn = "Customer"
olePram = oleCmdWrite.Parameters.Add("@Address", OleDbType.VarChar)
olePram.SourceColumn = "Address"
olePram = oleCmdWrite.Parameters.Add("@City", OleDbType.VarChar)
olePram.SourceColumn = "City"
olePram = oleCmdWrite.Parameters.Add("@State", OleDbType.VarChar)
olePram.SourceColumn = "State"
olePram = oleCmdWrite.Parameters.Add("@Zip", OleDbType.VarChar)
olePram.SourceColumn = "Zip"
olePram = oleCmdWrite.Parameters.Add("@Processed", OleDbType.VarChar)
olePram.SourceColumn = "Processed"
olePram = oleCmdWrite.Parameters.Add("@Used", OleDbType.VarChar)
olePram.SourceColumn = "Used"
olePram = oleCmdWrite.Parameters.Add("@Store", OleDbType.VarChar)
olePram.SourceColumn = "Store"

If IsNothing(ds) = False Then
dr = ds.Tables(0).NewRow
dr("TagNumber") = dgvTags.CurrentRow.Cells(0).Value
dr("ItemDescription") = tboxItemDescription.Text
dr("Source") = getSourceInfo()
dr("Customer") = tboxCustName.Text
dr("Address") = tboxAddress.Text
dr("City") = tboxCity.Text
dr("State") = tboxState.Text
dr("Zip") = tboxZip.Text
dr("Processed") = isProcessed()
dr("Used") = isNew()
dr("Store") = getStore()
oleAdpt = New OleDbDataAdapter
oleAdpt.UpdateCommand = oleCmdWrite
Dim str As String() = {"", "", "", "", "", "", "", "", "", "", ""}
For x As Integer = x To ds.Tables(0).Columns.Count - 1
str(x) = dr.Item(x)
Next x
Dim y As Integer = dgvTags.CurrentCell.RowIndex

ds.Tables(0).Rows.RemoveAt(y)
ds.Tables(0).Rows.InsertAt(dr, y)
dgvTags.CurrentRow.SetValues(str)
'oleConn.Open()
'oleCmdWrite.ExecuteNonQuery()
'oleConn.Close()
oleAdpt.InsertCommand = oleCmdWrite
Dim i As Integer = oleAdpt.Update(ds, "Sheet1")
MessageBox.Show(i & " Row(s) Affected")
disableFields()
End If



No errors are thrown when this block is ran, the message displays 0 rows affected, my data grid view is updated but no changes are actually writen to my excel file (the most important part).

Any and all help is much appreciated!

Thanks,

R

P.s. I have an INSERT statement that's somewhat similar to this that works perfectly, and I just don't have the expirence with writing to an Excel sheet to see where I errored. Thanks
 

Last edited by RnkG; 12-24-2008 at 06:56 PM..
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
From an ASP page, is there a way write to an EXCEL file without having EXCEL installed on the IIS machine ? fniles ASP General 6 04-27-2009 10:33 PM
Re: write float to Excel with pyExcelerator write John Machin Python 0 03-03-2008 12:14 PM
Re: write float to Excel with pyExcelerator write Peter Otten Python 0 03-03-2008 10:43 AM
if statement that, when false, skips first statement in its block, executes second? Jay McGavren Java 11 01-16-2006 05:49 PM
How do I do a conditional statement in a constant statement? tkvhdl@gmail.com VHDL 3 12-16-2005 06:13 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57