|
Excel Spreadsheets determine the datatype of a column, by looking at
the content of the first few rows. If it determines that the column is text,
then all numeric cells/fields are returned as null and if the column is
determined as numeric, then all text fields are returned as null.
Divya Rathi
|
|
|
|
|
I determined that the function itself is causing the problem. You say that the datatype is determined by the first few rows. The first 2 rows and first column of this file contain text, the rest is composed entirly of floating point numbers. From this function:
Public Function GetCellString(RowId As Integer, ColId As Integer) As String
Dim val As Double
val = xlSheet.Cells(RowId, ColId).Value
MsgBox val
GetCellString = xlSheet.Cells(RowId, ColId).Value
End Function
|
|
|
|
|
My code now looks like this
Public Function GetCellString(RowId As Integer, ColId As Integer) As String
If VarType(xlSheet.Cells(RowId, ColId).Value) = vbString Then
GetCellString = xlSheet.Cells(RowId, ColId).Value
ElseIf VarType(xlSheet.Cells(RowId, ColId).Value) = vbDouble Then
GetCellString = CStr(xlSheet.Cells(RowId, ColId).Value)
End If
MsgBox GetCellString
End Function
It is detecting a double, but it is only converting the numbers before the decimal point.
|
|
|
|
|
How do I get the contents of the current field and row from a datagrid?
I have set up the code to run when I click on a record in the datagrid and this works until you sort the datagrid by clicking on the column headers.
dim test as string
test = TestGrid.CurrentRowIndex
COMPANY.Text = CODE_DataSet.Tables(CODE_TABLE).Rows(test).Item(0)
Any Idesas?
|
|
|
|
|
|
There is an ItemCommand event that fires when you click something in the datagrid
one of the arguments for that event is DataGridCommandEventArgs let's call it "e"
myItemCommand (object sender, DataGridCommandEventArgs e )
{
e.Item.DataItem[0]; /*This a DataRowViewRow*/
}
That is how you access a row in a datagrid.
Please let me know if I missunderstood your question or there's anything else I can help you with.
Greetings,
Felipe
|
|
|
|
|
OK I think I have got what I am looking for with:
Dim MyCell As DataGridCell
Dim MyRow As Integer
Dim MyCol As Integer
Dim MyData As String
MyCell = TestGrid.CurrentCell
MyRow = (MyCell.RowNumber)
MyCol = (MyCell.ColumnNumber)
MyData = CODE_DataSet.Tables(CODE_TABLE).Rows(MyRow).Item(MyCol)
COMPANY.Text =MyData
This will work as long as there is data in the cell I clicked on.
How do I test for NULL?
What variable type do I need to set MyData so I dont get a compiler error
"Cast from type DBNull to type String in not valid"
|
|
|
|
|
IF IsDBNull(MyData) Then
COMPANY.Text=""
Else
COMPANY.Text=MyData
End IF
!alien!
|
|
|
|
|
|
Can you show the settings for the adapter under Button1_Click?
|
|
|
|
|
Hey Felipe thanks for your response...
I'm not quite sure what you mean by your question? I can see all the properties for my adapter...
|
|
|
|
|
Excume, but I don't see your command, or connection? where is you data comming from?
|
|
|
|
|
Oh, it is coming from my dataset object SQL server. Here is my connection:
Provider=SQLOLEDB;Data Source=main;Integrated Security=SSPI;Initial Catalog=SpringBooking
|
|
|
|
|
That's OK but I what I need is too see where in your code you are setting this code, your command will help too. But as I already said I need to see in which event and what code you have there to make this works...
|
|
|
|
|
I am trying to pull out info with an SQL statement, and order it by date before it arrives at my datagrid.
sComm += "SELECT Fixtures.HomeTeam, Fixtures.AwayTeam, Fixtures.Date FROM Fixtures WHERE (Fixtures.HomeTeam ='" + TName + "' or Fixtures.AwayTeam = '" + TName + "')ORDER BY Fixtures.Date"
It keeps giving me the error:
Syntax error (missing operator) in query expression 'Fixtures.DateSELECT Fixtures.HomeTeam'.
Cheers.
|
|
|
|
|
Ok, let's try first with everything hardcode, can you this pls:
" SELECT Fixtures.HomeTeam, Fixtures.AwayTeam, Fixtures.[Date] "+
" FROM Fixtures WHERE (Fixtures.HomeTeam =' TName ' OR Fixtures.AwayTeam = ' TName ' ) "+
" ORDER BY Fixtures.[Date] "
If this works then you have data problem a not..
|
|
|
|
|
I am sooooo dumb. Do you know what my problem was. I had messed about with the button that called the fuction. And I forgot to remove something, and it was calling the fuction twice.
Which is why I was getting "Syntax error (missing operator) in query expression 'Fixtures.DateSELECT Fixtures.HomeTeam'."
'Fixtures.DateSELECT Fixtures.HomeTeam'."
Because this..^ is where the first call ends and the other begins.
DOH'
Thanks anyway, its working now.
|
|
|
|
|
My first question has to be, what is in sComm before you this assignment. You are concatinating the select command to the value in sComm, so if sComm contains "Fixtures.Date", then you will end up with
"Fixtures.DateSELECT Fixtures.HomeTeam, Fixtures.AwayTeam, Fixtures.Date FROM Fixtures WHERE (Fixtures.HomeTeam ='" + TName + "' or Fixtures.AwayTeam = '" + TName + "')ORDER BY Fixtures.Date"
and of course this is not a proper sql command.
I would suggest changing
sComm += "SELECT Fixtures.HomeTeam, Fixtures.AwayTeam, Fixtures.Date FROM Fixtures WHERE (Fixtures.HomeTeam ='" + TName + "' or Fixtures.AwayTeam = '" + TName + "')ORDER BY Fixtures.Date"
to
sComm = "SELECT Fixtures.HomeTeam, Fixtures.AwayTeam, Fixtures.Date FROM Fixtures WHERE (Fixtures.HomeTeam ='" + TName + "' or Fixtures.AwayTeam = '" + TName + "')ORDER BY Fixtures.Date"
Hope this helps.
Roy.
|
|
|
|
|
I want to merge 6 pdf files to a single pdf file. i am
working with vb.net, can u please suggest any method
to achieve this using vb.net, pls help me
|
|
|
|
|
I want to have basic knowledge of password hacking , the logic involved , the concept involved behind the hacking . if any one can provide me with a sample code i will be very greatfull.
Thank you
|
|
|
|
|
I hope nobody gives you a serious answer to this, as the subject is not one that I think is accepable on this forum.
There are many many resources online for this sort of thing, CP is not one of them.
|
|
|
|
|
<br />
<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
Dim LocationOfOsamaBinladen as string<br />
Dim OsamaBinladensPasswordToBankAccount as string<br />
<br />
LocationOfOsamaBinladen = FindOsamaBinLaden(try-hard)<br />
OsamaBinladensPasswordToBankAccount = GetOsamaBinLardensPassword(try-even-harder)<br />
<br />
SendPasswordTo("KiloDunse**DK**")<br />
SendLocationTO("U.S Goverment")<br />
<br />
End Sub<br />
<br />
<br />
Private Function FindOsamaBinLaden(level-of-commitment) as String<br />
...<br />
End Function<br />
<br />
Private Function GetOsamaBinLardensPassword(level-of-commitment) as String<br />
...<br />
End Function<br />
Any questions?... don't ask me!
Programming is like Mathematics… you take ONE step at the time!
|
|
|
|
|
Hello,
I'm making a program that make use of Excel. In it, I create an Excel application and then make it visible, then perform several operations with it. Up to this point, everything OK.
The problem comes when I try to close the Excel. At first I thougt that, being an object created within my app, the process will be destroyed by the garbage collector. Then I realized that not. I tried to use the ExcelApp.Quit() method, but it doesn't work either.
In conclusion, I find myself with my program closed, but with a residual Excel process within an SVCHOST parent process I can't kill. Things turn to worse when I execute my app several times: I end up with several Excel processes, consuming no less than 8MB of memory each!!!
I invoke the Excel with the following code:
Imports Microsoft.Office.Interop.Excel
...
Private Excel As New Microsoft.Office.Interop.Excel.Application() ' el Excel
What can I do? Any help will be welcomed!
Thanks in advance,
Juan Pedro Pérez
|
|
|
|
|
Give this a try when you are done using Excel:
' Release Application object:
If Not oExcel.UserControl Then oExcel.UserControl = True
System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
'Release worksheet:
If Not oWorkSheet Is Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(oWorkSheet)
oWorkSheet = Nothing
End If
'Release workbook:
If Not oWorkBook Is Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(oWorkBook)
oWorkBook = Nothing
End If
oExcel = Nothing
oExcel is your Excel application object.
oWorksheet is your Excel worksheet object if you have one instantiated.
oWorkbook is your Excel workbook object if you have one instantiated.
Dean
|
|
|
|
|
Thanks Dean, I'll try this and I'll tell you how it works.
Juan Pedro Pérez
|
|
|
|