|
I can do that in a fast way with or without a database.
And everyone can come up with a slow implementation with or without a database. Getting it slow with a database is harder to achieve, since there is less code to mess with.
FYI: de database has to read the data from disk too, and search your string too, so why would it really be faster?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Dear Members,
I have a datagridview in windows form. In this grid one column is datagridviewcheckboxcolumn. when i select the first checkbox and i click a save button in toolstrip it will not work. But the same code in command button it is worked. Please check the following code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim arr As New ArrayList
Dim en As New TestEnity
en.Name = "name1"
arr.Add(en)
en = New TestEnity
en.Name = "name2"
arr.Add(en)
dgTest.DataSource = arr
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each row As DataGridViewRow In Me.dgTest.Rows
Dim checkBoxCell As DataGridViewCheckBoxCell = TryCast(row.Cells("dgvSelected"), DataGridViewCheckBoxCell)
If checkBoxCell IsNot Nothing Then
Dim checked As Boolean = CType(checkBoxCell.Value, Boolean)
If checked Then
MessageBox.Show("Row : " & row.Index & "Checked")
Else
MessageBox.Show("Row : " & row.Index & "Not Checked")
End If
End If
Next
End Sub
Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click
For Each row As DataGridViewRow In Me.dgTest.Rows
Dim checkBoxCell As DataGridViewCheckBoxCell = TryCast(row.Cells("dgvSelected"), DataGridViewCheckBoxCell)
If checkBoxCell IsNot Nothing Then
Dim checked As Boolean = CType(checkBoxCell.Value, Boolean)
If checked Then
MessageBox.Show("Row : " & row.Index & "Checked")
Else
MessageBox.Show("Row : " & row.Index & "Not Checked")
End If
End If
Next
End Sub
End Class
Public Class TestEnity
Dim _Name$
Public Property Name()
Get
Return _Name
End Get
Set(ByVal value)
_Name = value
End Set
End Property
sree
|
|
|
|
|
ToolstripMenu's Forms will be your MDI-Parent, and datagridview is in mdi_child, So you have to call by form5.My_Save()
So put your save-codes inside a sub and call it from mdi_parent as I gave.
|
|
|
|
|
I use a webservice to import the xml into a ms access database, and interop code is not working.
This is my code so far, but it is not working properly.
im strConnection As String
Dim objDataSet As New DataSet()
Dim objConnection As OleDbConnection
Dim objAdapter As OleDbDataAdapter
Dim intI As Integer
Dim ds As New DataSet
Dim streamRead As New System.IO.FileStream("C:\NTB100514_07_22_2009_225551.xml", System.IO.FileMode.Open)
ds.ReadXml(streamRead)
streamRead.Close()
If ds.Tables.Count > 0 Then
strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & "c:\PC Auditer.accdb"
objConnection = New OleDbConnection(strConnection)
objConnection.Open()
objAdapter = New OleDbDataAdapter()
Dim cb As New OleDbCommandBuilder(objAdapter)
For intI = 0 To ds.Tables.Count - 1
If ds.Tables(intI).Rows.Count > 0 Then
DataGridView1.DataSource = ds.Tables(intI)
objAdapter.SelectCommand = New OleDbCommand("SELECT * FROM [" + ds.Tables(intI).TableName + "] ", objConnection)
objAdapter.Fill(ds, ds.Tables(intI).TableName.ToString)
objAdapter.UpdateCommand = cb.GetUpdateCommand()
objAdapter.Update(ds, ds.Tables(intI).TableName.ToString)
End If
Next
objConnection.Close()
End If
In my access database all the primairy keys and relationships are defined. The first time (intI=0) the update command works well, but the second time (intI=1) iI get an error.
Kind regards,
Jurgen
ps: I am a beginner, so excuse me if my code is lokking so nice.
|
|
|
|
|
What is the error ? Have you stepped through in the debugger to see what is happening ? What line has the error ?
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.
|
|
|
|
|
Hi Christian,
The error is in line: objAdapter.Update(ds, ds.Tables(intI).TableName.ToString)
"Missing the DataColumn 'ID' in the DataTable 'Shares' for the SourceColumn 'ID'"
I don't have a datacolumn 'ID' in my table Shares. I think it has to do with the
primairy key and referential integrety. The previous table 'SOS' has a column ID (primairy key)
which has a relation with the column 'ID-Share' from table 'Shares'.
Kind regards,
Jurgen
|
|
|
|
|
There are four steps to it, which are defined below:
Step 1:
Click on External Data ribbon, go to the "Import" section and click on XML file option.
Step 2:
Use the browse option to go to the location where the XML file is located from which data needs to be imported. Click Open and then OK.
Step 3:
Access will scan through the file and display the structure of the table to be created. The Import Options includes the following options, namely Structure Only / Structure & Data / Append data to existing table. In our process we will choose the option of both structure and data.
Step 4:
If you plan to import the same file agian in the future then you can check the box "Save Import Steps".
Now you can double click on the table that is created and would be able to see the structure and the data in it i.e. imported from the XML file.
Eliza
http://www.mindfiresolutions.com/[^]Cheers,
Eliza
|
|
|
|
|
From Form-Load() I have query like the following
dim Query1 as string="Select * from My_Table"
Dim Da1 as SqlDataadapter,Ds1 as new Dataset,dtb1 as new datatable
con.open()
Da1=new sqlDataAdapter(Query1,con)
Da1.Fill(Ds1)
con.close()
dtb1=Ds1.Tables(0)
After some data's were added to the table "My_Table", and now from Combobox-Click(), I want to update it again..
Anybody can point me?
Thanks
|
|
|
|
|
Make your query a routine:
Private sub GetData()
dim Query1 as string="Select * from My_Table"
Dim Da1 as SqlDataadapter,Ds1 as new Dataset,dtb1 as new datatable
con.open()
Da1=new sqlDataAdapter(Query1,con)
Da1.Fill(Ds1)
con.close()
dtb1=Ds1.Tables(0)
' Update your UI here...
End Sub
then call this from both the FormLoad(...) event and the ComboBox._Click(...) event.
<edit -="" while="" this="" code="" is="" crap,="" it="" will="" work.="" make="" sure="" you="" are="" doing="" the="" correct="" cleanup="" etc.="">
Private Sub FormLoad(...)...
GetData()
End Sub
Private Sub ComboBox_Click(...)...
ComboBox.Items.Clear()
GetData()
End Sub
I don't speak Idiot - please talk slowly and clearly
I don't know what all the fuss is about with America getting it's first black president. Zimbabwe's had one for years and he's sh*t. - Percy Drake , Shrewsbury
Driven to the arms of Heineken by the wife
modified on Saturday, July 25, 2009 12:43 PM
|
|
|
|
|
ThankYou
|
|
|
|
|
Can anyone guide me to solve this problem.
i create a setup of outlook VSTO add-in. This setup is not working in Both Winodow XP and Vista.
So my friend suggest me that to write code in Outlook Share Add-In. I again create share Add-in Setup
and try to run in both machine. But Unfortunately it is not working in XP. And working successfully in Vista.
Can any one guide me which file needed to add in XP so my Share Add-in Work on XP also
Regards
DC
|
|
|
|
|
Please be patient - posting your question twice on the same page in the forum is SERIOUSLY bad form. People will answer, when and if they have the inclination.
In case you didnt notice, but it is the weekend in most of the world and most CP members do have a life outside of this site.
I don't speak Idiot - please talk slowly and clearly
I don't know what all the fuss is about with America getting it's first black president. Zimbabwe's had one for years and he's sh*t. - Percy Drake , Shrewsbury
Driven to the arms of Heineken by the wife
|
|
|
|
|
when I save date it save as for example 06:48 A.M
but i want it save such as 18:48
please help me
|
|
|
|
|
Tell me you are NOT saving your dates as strings (varchar()). A date should be saved as a DATETIME datatype, NEVER, EVER, EVER use text datatypes to save your dates.
If you store your date as Datetime then the format you DISPLAY the data is up to you, look at the datetime type.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi All,
I am sending mail by using my application and Opening Text File.
So antivirus shows my application to Spyware. my confution is that outlook and other software also send mail but they are now showing in spyware category.
So how to create my application to antivirus avoider. Because my application is not working any wrong activity.
and when i try to open log file. Antivirus shows it trying to use shell execution command.
So please help me how to resolve it.
If you can think then I Can.
|
|
|
|
|
You have to change what your code is doing, what access it requests of files, where the files it reads live, etc, until you satisfy the anti spyware program that you're not doing anything wrong.
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.
|
|
|
|
|
Thanks for reply,
But my second query is that why outlook not shows as Suspicious Activity performer. It also send mail.
If you can think then I Can.
|
|
|
|
|
Hi All,
I hope someone can asnwer this question?
Is it possible to resize the taskbar in xp using code?
I see many articles on hiding/showing the taskbar using SetWindowsPos
I have also tried using the SetWindowsPos to set its height with no susccess... hears what i got so far...
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
dim iCurW As Long, iCurH As Long
' lCurH already holds the current Height of the taskbar
' lCurW already holds the current Width of the taskbar
Private Sub cmdSet_Click()
Call SetWindowPos(TaskB, 0, 0, 0, iCurW, iCurH * 2, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE)
End Sub
I'm attempting to double the height of a single height taskbar any help would be appreciated.
|
|
|
|
|
This seems like a strange thing to want to do.
If it's your own system, simply alter the TaskBar height manually.
If it is somebody else's system, altering their settings is a bit rude. Some people take ages to get things just the way they like them, and then along comes some application and messes things up. That is the way to ensure they don't use your software ever.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
How can i search a record from a table.
If found, display the record.
if not found display a message
I have done the following:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Search.Click
Try
Me.RegistrationTableAdapter.FillByRegistration_(Me.RegisComplaintDataSet.Registration, Registration.Text)
If String.IsNullOrEmpty(Me.Registration.Text) Then
MsgBox("L'enregistrement n'existe pas" & UCase(Me.Registration.Text))
Me.Registration.Text = ""
Else
Me.Registration.Text = Me.Registration.Text
End If
Catch ex As Exception
End Try
End Sub
I am getting the result when it is found but no message when it is not
Thanks
|
|
|
|
|
Stick a breakpoint in your Catch block and see what error you're missing. I'd say it's probably coming back as a DBNull, and throwing an exception when you try to cast it into a string (Registration.Text).
You might have to put it in an object first, then check whether it's a DBNull (And display the message if so), and THEN cast it into a string if it exists.
|
|
|
|
|
Thanks,
I am not getting an error. when there is a match, I get the correct row record as the result..
when there is no match I get blank row record..
what i want is a message to display "no match for this" then a blank row.
I hope I make myself clear
thanks alot
|
|
|
|
|
Alright, well if you're absolutely sure it's not going into that Catch block (Notice that with an empty catch block, your program will just completely ignore any errors)...
If it's actually not triggering an error, then it's time to check the FillByRegistration_() function... Drop in some breakpoints and keep an eye on the values when you search for a non-matching record.
|
|
|
|
|
Thanks
I got the solution
|
|
|
|
|
Try using this in your "catch" block so see the error.
MsgBox(ex.ToString)
|
|
|
|