|
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
|
|
|
|
|
Hai,
I am facing the following problem when I am doing with my vb project,
In my program I need to copy files from Server to client. If client is not having sufficient privilages, then it should prompt for admin account and copy it in admin account.
When I try to copy a file through user account insufficient privilage message ,I got.
Through net ,I found that we can do it using 'Run as' command.
But i don't have clear idea to use it in VB.
Can anybody help me to show the right way to do this?
Thanks very much in advance.
Thank You,
rahul.p.menon
|
|
|
|
|
I've developed a website thro' and i'd like to see the suggestions of the users.
For that purpose i'd like to get the feedback from the users once they fill in the form.
The feedback must be sent to my email id automatically from the filled in information
when i tried i got the following error.................................
----------------------------------------------------------
the code goes like this
----------------------------------------------------------
Dim myMailServer As SmtpMail
myMessage.BodyFormat = MailFormat.Text
myMessage.Priority = MailPriority.High
myMessage.From = "xyz@urdomain.com" 'From Address
myMessage.To = "mymailid@mydomain.com" 'To Address
myMessage.Subject = "hi"
myMessage.Body = "hello"
myMailServer.SmtpServer = "smtp.net4india.com"
'This is my mail server
myMailServer.Send(myMessage)
myMessage = Nothing
----------------------------------------------------------
error msg is like this
----------------------------------------------------------
The transport failed to connect to the server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The transport failed to connect to the server.
Source Error:
Line 103: myMailServer.SmtpServer = "smtp.net4india.com" 'This is my mail server '
Line 104: myMailServer.Send(myMessage)
|
|
|
|
|
The SmtpServer property and Send method are static. Don't use a reference.
SmtpMail.SmtpServer = "smtp.net4india.com"<br />
SmtpMail.Send(myMessage)
---
b { font-weight: normal; }
|
|
|
|