|
Hello,
Thanks for answering my question.
I have found the problem. There Where 21 colomns, my mistake forgotten to count from 0 but i started from 1 so there was no 21 colomn.
Can you please give me a small example how i can optimize my SQL commands. for example where hotel ='" + hotel + "'"
Thanks for helping me further.
Best regards
DCA
|
|
|
|
|
DCAUB wrote: Can you please give me a small example how i can optimize my SQL commands
See this article on SQL Injection Attacks[^] and read the section on Parameterised Queries. In fact, you should read the whole thing in order to fully protect yourself.
|
|
|
|
|
I checked in msdn forum as well but there is one thread still pending not getting the answer of the similar problem, so I thought of posting it here.
Lets get the picture of the problem first.
1. I have a form called cat where I have one field called CatName where I save the data.
2 I have another form where I have got Combo box where I load cats when form loads.
Now question is imagine I have more than 40 fields in the form 2 where user filled up 39 fields but when he came to cats combo box then he found that one cat is not there so he opens cat form to add the new cat in it.
Then how can i acheive this without opening a new form.
Here is what i have tried so far
this is the sub where i load cats in combobox:
Public Sub LoadCats(ByVal cboCats As ComboBox)
Dim objdb As New clsObjDB
Dim ds As New DataSet
Dim str As String
cboCats.Items.Clear()
str = "Select * from cat order by catID desc"
ds = objdb.getDataset(str)
Dim dt As DataTable
dt = ds.Tables(0)
For Each row As DataRow In dt.Rows
cboCats.ValueMember = row("CatID")
cboCats.Items.Add(row("CatName"))
Next
End Sub
Now in cat I tried
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Dim objdb As New clsObjDB
Dim str As String
If txtCatName.Text.Trim = "" Then
MessageBox.Show("Enter the Cat Name")
txtCatName.Focus()
objdb = Nothing
Exit Sub
End If
str = "Insert into cat(CatName)values('" & txtCatName.Text & "')"
objdb.ExecuteQuery(str)
MessageBox.Show("Success")
'*****************************************
'Now my save is finished so over here i tried loading of cbocats
Dim frm As dog
'********* Here is the problem I can't do new here because the user wants to stay on the same page he was working on.
LoadCats(frm.cboCats)
Me.txtCatName.Text = ""
End Sub
Hope you guys get the point, I am very poor in explaining these sort of things....
Thanks in advance
|
|
|
|
|
rprateek wrote: Dim dt As DataTable
dt = ds.Tables(0)
For Each row As DataRow In dt.Rows
cboCats.ValueMember = row("CatID")
cboCats.Items.Add(row("CatName"))
Next
Instead of adding each cat to combobox
Why dont you set datasource, displaymember and valuemember?
If you are using a different form to add, update and delete from your cats catalog, just call that form from your cat form (as you are doing now) using showdialog and after that, just call your loadcats again to refill combobox
I didnt really understand what you are doing, but this should work
Alexei Rodriguez
|
|
|
|
|
ya i understand your point but i didn't mean that..
you can try it yourself I just want is one form for eg form1 open where we have cbobox where we have cats.
now as per your advice i did datasource and data member .
ok i opened the dialog box to insert new cat.
Now how would you load the cats in the same form called form1 that is open.
where you have to do following to load cats
LoadCats(frm.cboCats)
but if you don't do frm= new frmCats then it will show error ..... so how to overcome this.?????????
|
|
|
|
|
hey guys please have a look into this
|
|
|
|
|
Hi, thanks for looking
I need to minimizee all maximized windows
I tried this and it kind of works:
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each p As Process In Process.GetProcesses
ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_MINIMIZE)
Next
Me.WindowState = FormWindowState.Normal
End Sub
The thing with this is that i dont want to iterate thru each process
Now, im trying the sendkeys function to send Window + D to minimize all open windows, but i cant find the window representation, ive found this:
SendKeys.Send("(^{ESC}{D})")
But this doesnt do nothing on my pc, maybe because of my keyboard settings or something
Does anyone have any other suggestions??
Alexei Rodriguez
|
|
|
|
|
Hi Alexei,
Use the following code:
<br />
Public Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Int32, ByVal dwExtraInfo As Int32)<br />
<br />
Public Sub MinimizeAll()<br />
keybd_event(&H5B, 0, 0, 0)<br />
keybd_event(&H4D, 0, 0, 0)<br />
keybd_event(&H5B, 0, &H2, 0)<br />
End Sub<br />
The first line declares the API. Next piece of code is a method which we can call anywhere to minimize all windows...
I hope this would be helpful.
John Adams
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Thanks for your answer, it works great
I am trying to restore my window program after all wndows are minimized
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Timer1.Enabled = False
Me.MinimizeAll()
Me.WindowState = FormWindowState.Normal
End Sub
But this doesnt work
I tryed putting the current thread to sleep for a second, but didnt work either, it looks like keys are not being processed imediatelly, do you know of any workaround?
All i need to do is to minimize all windows and restore the window of my program
Thanks in advance
Alexei Rodriguez
|
|
|
|
|
I have a button with a call to the minimizeall method.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MinimizeAll()
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Enabled = False
Me.WindowState = FormWindowState.Maximized
End Sub
Works fine. that way. I tried your method and through the button click, but there is a timing issue with the minimizing and the maximizing. Break them out into sep routines and it works fine.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Yes, enabling a timer to restore my window after the call to the minimize works fine
I guess the keys are not imediatelly processed and calling thread.currentthread.sleep(1000) stops the whole app and makes no difference
There must be some way to force the keys to be processed
Thanks for the tip
Alexei Rodriguez
|
|
|
|
|
|
Is there a better way than this to parse through a string to break up the vatious elements?
Example of what I'm doing now...
Dim strTemp As String
Dim tst,tst1,tst3,tst4,tst5,tst6,tst7 As String
Dim Name1,Name2,Name3,,Name4,Name5,Name6,Name7 As String
strTemp = "Name1:Name2/Name3.Name4.Name5.Name6.Name7"
tst = strTemp.IndexOf(":")
Name1 = strTemp.Substring(0, tst)
tst1 = strTemp.IndexOf("/")
Name2 = strTemp.Substring(tst, tst1 - tst)
Name2 = Name2.TrimStart(":")
tst2 = strTemp.IndexOf(".")
Name3 = strTemp.Substring(tst1, tst2 - tst1)
Name3 = Name3.TrimStart("/")
tst3 = strTemp.IndexOf(".")
Name4 = strTemp.Substring(tst2, tst3 - tst2)
Name4 = Name4.TrimStart(".")
There must be a better way, what am I missing??
TIA
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Use the Split[^] function to automatically split the string up into an array.
|
|
|
|
|
Thanks....This more what I had in mind. I think I learned about the Split Function 3 or 4 years ago and forgot it.
Using this is like a little toolbox in itself!
Thanks again..If you have any other tips on how to use this I would be much ablidged...
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Since you have multiple characters to split on, you could also use regular expressions. In this case the pattern would probably be [without the space between : and (]
([^:]+): ([^/]+)/([^.]+)\.([^.]+)\.
That pattern may not be correct; I just typed it in to the reply without testing it. If you have not used regular expressions before, they are much to big a topic to cover here but are well worth learning.
As a side note, your example will give test3 = test2 since both will find the first period. Also, if you used Name2 = strTemp.Substring(tst + 1, tst1 - tst) you would not need to trim the start
|
|
|
|
|
Hi All,
am using VB.NEt 2.0 ,I have some promlem to display the values on List box Control.
am getting this type of error
Complex DataBinding accepts as a data source either an IList or an IListSource.
My Code is
Private Sub loadEmpValues()
lbxEmpValues.datasource = o_ima.getdata.tables()
lbxEmpValues.Displaymember = "VALUES"
End Sub
Regards
Vidhish
|
|
|
|
|
vidhish wrote: lbxEmpValues.datasource = o_ima.getdata.tables()
Looks like you are trying to bind the listbox to possibly multiple tables(therefore complex binding).
What type does getdata return, presumably a dataset which is Ok for a datagrid but not for a listbox.
Ok so I never use a listbox
Bind a SINGLE table to the listbox, then set the display and value members to the appropriate fields in the table. Looks like you treat it like a combobox withut the drop down!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Private Sub loadEmpValues()
lbxEmpValues.datasource = o_ima.getdata.tables(0)
lbxEmpValues.Displaymember = "VALUES"
End Sub
--
"Keyboard not found. Press < F1 > to RESUME. "
Source unknown (appears in many common BIOSes as a real error message)
|
|
|
|
|
Hi All,
am using VB.NEt 2.0 ,I have some promlem to display the values on List box Control.
am getting this type of error
Complex DataBinding accepts as a data source either an IList or an IListSource.
My Code is
Private Sub loadEmpValues()
lbxstatus.datasource = o_ima.getdata.tables()
lbxEmpValues.Displaymember = "DESCRIPTION"
End Sub
Regards
Vidhish
|
|
|
|
|
Oh and try and refrain from double posting, it only irritates people and will require you to get a flame proof suit if you persist!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Dear gents
I am updating a dataset dynamically using a for loop. When the loop is executed each time, it will fetch some rows from the database and update the dataset.
My requirement is i wanna display only the first row after the end of each execution of loop.
datagridview1.datasource=ds.tables(3).rows(i)(0) is not working
Please help me ASAP
Ahamed Azeem
software Programmer
|
|
|
|
|
You might want to take a look at creating a view of the Dataset table, filter the view so that it only has the row(s) you want to display in the grid, and then assign the datasource of the grid to the view.
Something like...
Dim dView = New DataView(ds.Tables(3))
dView.RowFilter = "SomeKey = '" & ds.Tables(3).Rows(0)("KeyColumnName") & "'"
datagridview1.DataSource = dView
|
|
|
|
|
Language in use: Visual basic 2008
I am reading a COFF .out file using a binaryreader from within VB. After reading it, I am converting it to hexidecimal format.
However, the structure of the file is not apparent either before the conversion or after it. I am able to actually read some of the ASCII comments within the file. However, I am pretty sure there is address information available within the file along with data, probaby in a hex form or something similar.
Is there an easy way to determine the internal structure "or lack there of"? of a binary file using VB. I am confident this file has internal structure/sections of some sort because I have created a binary file and it is not recognized as a COFF file. Is there or can there be Crlf's within a binary file. If I try to read the file as a text file, all I get is one ASCII symbol "ASCII code 0xC1 or something similar".
I am trying to determine the format because I need to create a customized .out file that contains a serial number only and store that at the proper address location.
Usually, the COFF file is created on a development system and I believe the .out file also contains linker information. In this paritular case, the .out file is for programming a DSP and adding the serial number withn each DSP device. The development station or emulator package is not an option being as the solution needs to be an automated self-contained for use within a production environment.
"old forum members jump to conclusions, while others search for the real solutions."
|
|
|
|