|
I don't know in detail your source code of the GroupBoxNew. However, I try creating GroupBoxNew simply by declaring a usercontrol which is inherited from GroupBox. As a result, I can manipulate on the GroupBoxNew like available GroupBox. I think that maybe you override some functions of the GroupBox during creating the GroupBoxNew. good luck to you! <vtalau>
|
|
|
|
|
Hi all,
I'm using VB.NET and I can read my XML into a dataset and display it into a DataGrid with no problem. But what I would like to do (if possible) is select certain elements via an id attribute.
For example, if my XML had the following nodes:
<br />
<mynode id="someid">innertext</mynode><br />
<mynode id="someid">someotherinnertext</mynode><br />
<mynode id="someid">more innertext</mynode><br />
<mynode id="someotherId">innertext</mynode><br />
How would I be able to display only those nodes with id="someid" and bind my dataset to my Datagrid.
Is this even possible to do or will I have to create another XML document to parse and hold only those specific nodes?
Any help would be much appreciated! Thanks.
|
|
|
|
|
My example got cut off...it was: if my XML had the following nodes:
<&mynode id="someid" > innertext </mynode>
<&mynode id="someid" >someotherinnertext </mynode>
<&mynode id="someid" >more innertext </mynode>
<&mynode id="someid" >innertext </mynode>
|
|
|
|
|
oops...and then another line:
<mynode id="someotherId" > more text </mynode>
A different id should be included! sorry!
Again...how would I select only those text values where id="someid" ?
|
|
|
|
|
I am making a small program. Actually on my form there are two comboboxes. From these two comboboxes, user specify the search criteria.
In first combobox, there are alphabets from A-Z. In second combobox, there are selection criteria like "search By Author", "search by publisher" etc.
I just show data in a datagird.
I use the following code.
''' This code is used for concatenation % sign to use in like operator'''''''
Dim var1
var1 = Me.ComboAlphabets.Text()
var1 = var1 & "%"
MsgBox(var1)
''''Gettiong values of combobox'''''''''''''
Dim searchby
searchby = Me.ComboSearch.Text()
MsgBox(searchby)
Dim da As New SqlClient.SqlDataAdapter("SELECT * from books where '" & Me.ComboSearch.text & "' like '" & var1 & "' ", cn)
Dim ds As New DataSet
If da.Fill(ds, "books") = Nothing Then
MsgBox("No Record Found")
Me.ViewBookGrid.Hide()
Else
ds.Clear()
Me.ViewBookGrid.Show()
Try
da.Fill(ds, searchby)
Me.ViewBookGrid.DataSource = ds.Tables(searchby)
Catch ex As Exception
MsgBox(ex.Message)
End Try
MsgBox("Records Found")
End If
Everything is run fine , but there is a problem in select query after the where clause. Actually i want to select those records from database which user has mentioned from combobox. Like if user select "Publisher name" from combo box, then it select record from "publishername" column only.
I use the query, it works 100% fine
'Dim da As New SqlClient.SqlDataAdapter("SELECT * from books where publihsername like '" & var1 & "' ", cn)
At "publishername", i want to mention combosearch.text values. Means if i select "Publishername" from combobox, then my query becomes.
'Dim da As New SqlClient.SqlDataAdapter("SELECT * from books where publihsername like '" & var1 & "' ", cn)
If i select "AuthorName", then my query becomes
'Dim da As New SqlClient.SqlDataAdapter("SELECT * from books where authorname like '" & var1 & "' ", cn)
I try a lot and use this query
Dim da As New SqlClient.SqlDataAdapter("SELECT * from books where '" & Me.ComboSearch.Text & "' like '" & var1 & "' ", cn)
But this query cannot fetch correct result. If i exclude me.combosearch.text from query and replace this with "publishername" or "authorname", then it works fine.
kindly tell me that how to refine this querty, so that it will work fine,
plz reply
eshban
EsHbAn BaHaDuR
|
|
|
|
|
eshban284 wrote:
Dim da As New SqlClient.SqlDataAdapter("SELECT * from books where '" & Me.ComboSearch.Text & "' like '" & var1 & "' ", cn)
You're putting quotes around the tablename. You shouldn't.
Also, LIKE doesn't do anything unless you put % on either side of the string. And finally, you're wide open for SQL injection attacks with this code.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
Also, LIKE doesn't do anything unless you put % on either side of the string
% is the wildcard so having Like 'A%' searches for anything beginning "A" - it is not necessary to have the wildcard on either side.
|
|
|
|
|
Christian Graus wrote:
You're putting quotes around the tablename. You shouldn't.
I think you mean column name and not table name. And to clarify, you shouldn't be putting single quotes around the column name.
|
|
|
|
|
Hi,
Thank you for your reply. Now my code runs fine. I just exclude single quotes. As far as like operator is concerned, i concat the % sign with the alphabets like A,B or C etc.
Thank you
EsHbAn BaHaDuR
|
|
|
|
|
I have an Explorer-Style ListView and I use
ListView1.View = View.Details<br />
ListView1.View = View.LargeIcon<br />
ListView1.View = View.List<br />
ListView1.View = View.SmallIcon
to update the respective view.
I added the ability to view thumbnails with this code:
Dim fullPath As String
Dim di As New DirectoryInfo(fpath)
Dim fi As FileInfo
Dim i As Integer
fullPath = GetPathFromNode(TreeView1.SelectedNode)
ListView1.Items.Clear()
'*** Loop to get the "jpg" files
Try
For Each fi In di.GetFiles("*.jpg") ' if path will contain link files, change from jpg to lnk
ImageList3.ImageSize = New Size(96, 96)
Try
CreateThumbNail(fpath & "\" & fi.Name) ' This returns the thumbnail images
With ListView1 ' set the properties for for the ListView ListView1
.Items.Add(fi.Name, i)
.LargeImageList = ImageList3
.ForeColor = Color.Blue
.Scrollable = True
End With
Catch
Exit Try
End Try
i += 1
Next ' cycle through fpath until no more *.jpg.lnk files are found
Catch
MsgBox("No image files are located in this directory.", MsgBoxStyle.Exclamation, "Thumbnails")
Exit Try
End Try
Private Sub CreateThumbNail(ByVal filepath As String)
Dim myImage As New Bitmap(filepath)
Dim MyThumbNail As Image
'*** ThumbNail
MyThumbNail = myImage.GetThumbnailImage(96, 96, AddressOf Thumbnailabort, Nothing)
'*** Fill the ImageList with Image Collection
ImageList3.Images.Add(MyThumbNail)
End Sub
The four ListView1.View = * work just fine until I execute the routine to view thumbnails. After viewing thumbnails the four ListView1.View = * routines do not work properly. Among the problems is that only jpg’s are listed in the ListView.
Any ideas or suggestions?
Thanks
Brad
|
|
|
|
|
I have a Names datatable with FirstName and Namesid columns. I'm using the following code to drive the list for the combobox.
ComboBox1.DataSource = "DataSetNames"
ComboBox1.DisplayMember = "name.firstname"
I have an Orders datatable with OrderDate and Namesid columns. When a name is choosen form the combobox list how do I write the corresponding Namesid back to the Orders table Namesid column?
Thanks in advance for any help.
|
|
|
|
|
Add this to your binding:
ComboBox1.DataSource = "DataSetNames"<br />
ComboBox1.DisplayMember = "name.firstname"<br />
ComboBox1.ValueMember = "name.Namesid"
Then when you select an item in the combox...you can return
ComboBox1.SelectedValue
which should contain the corresponding Namesid.
|
|
|
|
|
I have a textbox where a user enters his/her id number. After a click event, I want to take that id number and compare it to the id that is stored on my sql server database table, then allow the user to either proceed or stop. Any ideas how to do that?
Shannon P.
|
|
|
|
|
Use SQL to check if the value is in the table. Use the result of the SQL to decide what to do next.
More specific help would require an idea of your overall setup, and which part of this task is causing you problems.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
What I'm attempting to do is to validate what a user's id is within a textbox with what is stored within the sql server database. If the id on the textbox matches what is inside the database, begin the application. If not, display an error message to user. That is what I'm attempting to do. Any ideas would be greatly appreciated.
Shannon P.
|
|
|
|
|
Christian gave you an idea that would work. What's the problem?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
My problem begins at "myCommand.ExecuteScalar()". My try...catch error handler reads, "Invalid object name: EmpId". My table has a column labeled "EmpId" so I'm not actually sure what the problem is. Any ideas?
Shannon P.
Dim myConnection As New System.Data.SqlClient.SqlConnection
myConnection.ConnectionString = "workstation id=SHANNON-OUYIJ2M;packet size=4096;integrated security=SSPI;data source=SHANNON-OUYIJ2M;persist security info=False;initial catalog=WorkInstructionLibrary"
'Create a parameterised command that will return the number of matches.
Dim myCommand As New SqlCommand("SELECT COUNT(*) FROM EmpID WHERE EmpID = @employeeId", myConnection)
'Set the parameter values to the credentials entered by the user.
myCommand.Parameters.Add("@employeeId", SqlDbType.Int).Value = Me.txtEmpId.Text
myConnection.Open()
Try
Dim count As Integer
count = CInt(myCommand.ExecuteScalar())
If count = 0 Then
'generic fail message
Else
'allow application to proceed
End If
Catch ex As SqlException
Dim errorMessages As String
Dim i As Integer
For i = 0 To ex.Errors.Count - 1
errorMessages += "Index #" & i.ToString() & ControlChars.NewLine _
& "Message: " & ex.Errors(i).Message & ControlChars.NewLine _
& "LineNumber: " & ex.Errors(i).LineNumber & ControlChars.NewLine _
& "Source: " & ex.Errors(i).Source & ControlChars.NewLine _
& "Procedure: " & ex.Errors(i).Procedure & ControlChars.NewLine
Next i
Dim log As System.Diagnostics.EventLog = New System.Diagnostics.EventLog
log.Source = "My Application"
log.WriteEntry(errorMessages)
Console.WriteLine("An exception occurred. Please contact your system administrator.")
MessageBox.Show("Error: EXECUTESCALAR METHOD" & errorMessages.ToString & " <> " & ex.ToString, "Error executing EXECUTESCALAR METHOD", MessageBoxButtons.OK)
End Try
|
|
|
|
|
Found the solution! My EmpId should have been my table name. Stupid syntax error on my part! Thanks to all.
Shannon P.
|
|
|
|
|
hi,
i want to make a program that will stand between a program i use and the server it connects to so i can see the packets moving between them.
the question is, how i make my program redirect the ip:port of the other program to go through it ?
should i use winsock ? inet ? in which way ?
any suggestions ?
|
|
|
|
|
If you want to write it yourself, you have two options. You can either write your own proxy or your own network monitor. Either way, it's alot of work. Or you can use the Network Monitor that comes with Windows Servers.
No matter what, I would suggest Googling for "network packet capture windows". Clickety[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Does anybody know if there is a (one command) way to change the BackColor of all controls in a form as well as the form itself?
I have an application with several forms and controls and I want to “spruce up” the look a little bit.
Thanks
Brad
|
|
|
|
|
Nope. You'll have to enumerate all the controls on the form and change them, one by one.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Okay...that's what I was affraid of.
Thanks.
|
|
|
|
|
Is it possible to create a MultiLine list box?
Any references that could point me in the right direction? Thanks!
|
|
|
|
|
Do you mean add items?
Here is how you add items:
lstBoxAddItem.Items.Add
|
|
|
|