|
Hi all, how can i insert excel worksheet in vb.net form that can be applied excel formula in the worksheet.
Thanks in advance..
Regards
|
|
|
|
|
Hello Thare
I am new at this but i am also working with excel and found this site that was very usfull hope it is usfull for you too
http://vb.net-informations.com/excel-2007/vb.net_excel_2007_create_file.htm
look at the bottom of the page thare is all kinds of Related Contents
|
|
|
|
|
I am assuming what you are saying is that you want to disply an Excel worksheet in a form. You could link to Excel using Excel as a COM server (objExcel as Excel.Application) or you could get an excellent control like Spreadsheet Gear which makes what I am assuming you want to do very easy.
If you search the message boards here with 'using excel in vb' you will get 31 pages of results. You might find something useful there!
Alternatively you might find this useful: ExcelSpreadsheet.aspx
|
|
|
|
|
you could use OWC (office web control) to show the excel files and work with it on a form.
|
|
|
|
|
Hi,
I want to add new control at run time . I had written the code to add a new control to the Main Panel in the Data recieved event of the Serial port like this : -
Public Sub portname_DataRecieved()
Dim pnl as new Panel()
Dim pts As New System.Drawing.Point(pt.X, pt.Y)
pnl.Location = pts
pnl.BackColor = System.Drawing.Color.YellowGreen
MainPanel.Controls.Add(pnl)
End Sub
But I am getting the error at the line MainPanel.Controls.Add(pnl) that is cross-thread operation is not valid how can I remove it.
Thanks
|
|
|
|
|
Use current forms Invoke method to call MainPanel.Controls.Add method, hopefully it will resolve the issue.
|
|
|
|
|
I had tried the following code : -
If MainPanel.InvokeRequired Then
MainPanel.Invoke(AddControlToConatiner)
End if
Public Function AddControlToConatiner()
pnl.Location = pts
pnl.BackColor = System.Drawing.Color.YellowGreen
MainPanel.Controls.Add(pnl)
Return 0
End Function
but the problem still remains the same what is the error can u tell or an example
|
|
|
|
|
You're creating a control on a background thread. Don't. Have the AddControlToContainer method create the control. All controls should be created on the UI thread, not on a background thread.
|
|
|
|
|
Hi all
I'm trying to get a value of a column in DataGrid and insert it in Oracle Table. Below is my code.
Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) Handles GridView1.RowDeleting
Dim oradb As String = "Data Source=(DESCRIPTION=" _
+ "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=Mahasilbkp.ltuisb.net)(PORT=1521)))" _
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=db21a)));" _
+ "User Id=" + Label5.Text + ";Password=<pass>;pooling=false;enlist=false;"
Dim conn1 As New OracleConnection(oradb)
conn1.Open()
Dim cmd1 As New OracleCommand
cmd1.Connection = conn1
GridView1.DataBind()
Dim val As Label = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
cmd1.CommandText = "insert into uu.record_backup(ntn, name, status, enf, aud, sector, delete_user) select ntn, name, status, enf, aud, sector" + ",'" + Label5.Text + "'" + " " + "from uu.total_cases where trim(ntn)='" + val.Text.ToString + "'"
Dim dr1 As OracleDataReader = cmd1.ExecuteReader()
dr1.Read()
dr1.Dispose()
dr1.Close()
cmd1.Dispose()
conn1.Dispose()
conn1.Close()
End Sub
When I click on Delete it gives the following error:
Object reference not set to an instance of an object.
Source Error:
Line 49: cmd1.CommandText = "insert into uu.record_backup(ntn, name, status, enf, aud, sector, delete_user) select ntn, name, status, enf, aud, sector" + ",'" + Label5.Text + "'" + " " + "from uu.total_cases where trim(ntn)='" + val.Text + "'"
If I remove the "val.Text" from the above code then it works, but obviously the results are not as I desire. Please help me with this.
Thanks.
|
|
|
|
|
val.Text.ToString ?? What is the object val ??
If it is a text box, try naming it to something else.
|
|
|
|
|
val is a declared label to store the data from the NTN column of the grid
Dim val As Label = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
Thanks.
|
|
|
|
|
I suspected that. Probably not a good idea to have a label with the same name as a VB function. I am not saying that this is the cause of your problem, but try renaming that label first. Dim lblNTN As Label would be much more readable.
Actually looking at this, where is this label being created?
Dim val As Label = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
What is control "NTN"?
|
|
|
|
|
As TheComputerGuy said and then try:
Dim lblNTN As New Label
lblNTN = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
My advice is free, and you may get what you paid for.
|
|
|
|
|
Ok guys i tried that, but I am still getting that "Object reference not set to an instance of an object" on the insert statement.
Just want to clarify that "NTN" in
lblNTN = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
is the name of the column of the Data Grid from which I want the data to be retrieved. Am I doing it the correct way? If not please help with this.
Thanks.
|
|
|
|
|
You might as well just forget about the label completely, and try something like this:
cmd1.CommandText = "insert into uu.record_backup(ntn, name, status, enf, aud, sector, delete_user) select ntn, name, status, enf, aud, sector" _
& ",'" & Label5.Text & "'" & " from uu.total_cases where trim(ntn)='" _
& GridView1.Rows(e.RowIndex).Cells("NTN").Value & "'"
My advice is free, and you may get what you paid for.
|
|
|
|
|
Ok guys "GridView1.Rows(e.RowIndex).Cells("NTN").Value" gives error on the "value" as it does not recognize it. So I used "GridView1.Rows(e.RowIndex).Cells("NTN").Text". Now I am getting the following error
System.FormatException: Input string was not in a correct format.
it is coming on this line.
Line 54: cmd1.CommandText = "insert into uu.record_backup(ntn, name, status, enf, aud, sector, delete_user) select ntn, name, status, enf, aud, sector,'" + Label5.Text + "' " + "from uu.total_cases where trim(ntn)='" + GridView1.Rows(e.RowIndex).Cells("NTN").Text + "'"
Please help me where I am making mistake in the above line.
Thanks for your help.
|
|
|
|
|
Hi all, i want to retrieve value from dataset. I build dataset from sql data adapter,
Dim strSQL As String
strSQL = "select name FROM sysobjects WHERE xtype='U' and name = 'OPEX" & Str(jumtbl) & "'"
Dim dachecktable As SqlDataAdapter = New SqlDataAdapter(strSQL, oConnection)
Dim dschecktable As New DataSet
dachecktable.Fill(dschecktable, "DSchecktable")
If dschecktable.Tables(0).Rows.Count > 0 Then
----> how can i retrive the item data from dataset dschecktable
' strSQL = "drop table "
End If
Thanks in advance
|
|
|
|
|
What have you tried ? What does MSDN say ?
You already have the code to check if there's rows in the table ( although it does assume one table exists ). You can foreach over the rows, or address them by index. Then for each row, you can index fields or address them by name
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I found it at last, i have to create datarow first, this what i got, advice me if there is better way.
Thank you
|
|
|
|
|
you don't *create* a datarow, you iterate over the ones that are already in your table.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Once you get populated dataset all you need is to first get corrosponding table and then you can either iterate over rows of table or try find method available on DataTable. For example
DataTable dataTable = dataSet.Tables[0];<br />
foreach(DataRow dataRow in dataTable.Rows)<br />
{<br />
Response.Write(dataRow["column_name"].ToString());<br />
}
|
|
|
|
|
Hi to all.
I have a little problem with a cicle For-Next:
Reduced sample of my code:
For A = 1 To B
If "Condition" = True Then
B = B - 1
End If
Next
This apparently simple code works correctly until A is less than 50 (half cicle, then it cause an error.
I understood that the problem is that the variables B is initially set to the specified value 100 and it is not updated during the cicle For.
I can't use a cicle Do-loop.
I can't predict the final value of B.
How I can resolve the problem?
Thanks
modified on Wednesday, September 2, 2009 5:03 PM
|
|
|
|
|
I'm not sure exactly what you want your end result to be, but I'm wondering if it's not this:
B = 100<br />
For A = 1 To 100<br />
If "Condition" = True Then<br />
B = B - 1<br />
End If<br />
Next
If you always want it to loop 100 times, just set it to 100. Or if that varies as well, just setup another variable to hold the value you are looping to. Like this:
B = 100<br />
C = 100<br />
For A = 1 To C<br />
If "Condition" = True Then<br />
B = B - 1<br />
End If<br />
Next
|
|
|
|
|
Thanks for reply.
Excuse me,
In the sample I assumed B = 100 only for exsample, but in reality the initial value of B is variable.
B rapresents the total records of a file, and initially it's unpredictable.
During the cicle for these records will be reduced to an unpredictable value.
modified on Wednesday, September 2, 2009 5:16 PM
|
|
|
|
|
So does this work for you?
B = 100<br />
C = 100<br />
For A = 1 To C<br />
If "Condition" = True Then<br />
B = B - 1<br />
End If<br />
Next
Or is there a problem that I'm not understanding? If you're still having trouble, it would help us to know more about the end result your looking for.
|
|
|
|