Click here to Skip to main content
15,923,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
u know... then answer this,
im uploading .xls file. but i want to check whether the file im uploading consist productname and price(this r 2 header), then only it should upload. otherwise it shouldnot....can anybody send the code using vb.net. this how im uploading .xls file... now add next code how 2 check?

please reply
thanks in adv.
send the next part code using vb.net


Protected Sub UploadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) If (FileUpLoad1.HasFile And FileUpLoad2.HasFile) Then
FileUpLoad1.SaveAs("C:\Documents and Settings\Administrator\My Documents\anil\" + FileUpLoad1.FileName) Label1.Text = "File Uploaded: "; + FileUpLoad1.FileName FileUpLoad2.SaveAs("C:\Documents and Settings\Administrator\My Documents\anil\"; + FileUpLoad2.FileName) Label2.Text = "File Uploaded:" + FileUpLoad2.FileName Else Label1.Text = "No File Uploaded."
Label2.Text = " No File Uploaded."
End If End Sub
Posted

anilsarda777 wrote:
but i want to check whether the file im uploading consist productname and price(this r 2 header), then only it should upload.


Can't be done. how do you check the contents of a file without uploading it first ?

Your code will run after it's uploaded, so that is OK. I think I've read this code and question before, do you have more than one account ?

Here[^] is a ton of info on how to read an Excel sheet in VB.NET. Notice how I got it ?
 
Share this answer
 
///use select with condition



cmd2.CommandText = "SELECT * INTO [MS Access;Database=" & Acces & "].[Table1] FROM [Sheet1$] Where ProductName = Productname and price = price"

cmd2.ExecuteNonQuery()


//if condition is true then only it will take if not it will generate error. for that use: on error goto

nextstep:
MsgBox(" wrong informat")
Response.Write("UPLOAD.1 CONTAINS WRONG EXCEL FORMAT")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900