|
hello all,
am creating an application using vs.net2005 and sql server as a backend and vb as my code begin. my problem is am setting eno as a primary key field in that field an user entered a number which is alreay in the database it was shown some msg(that no is in the database please choose different no) am writing code for thi. but it is not working propherly. cause when ever user enter no it was check that condition and the clear again he put the same no in the text it was not show that message. am attaching my code. please help me to solve the issue....
Private Sub txteno_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txteno.Leave
con.Open()
Dim A As Integer
A = txteno.Text
str = "select eno from empl"
cmd = New OdbcCommand(str, con)
While Not rs.EOF
'If (A = rs.getvalue("eno")) Then
If (A = rs.Fields(0).Value) Then
MsgBox("Eno Already in DataBase so Please select Different No")
txteno.Text = ""
End If
rs.MoveNext()
End While
con.Close()
End Sub
|
|
|
|
|
1) you can bypass the while loop by putting the value of the textbox in the where clause of the select statement
str = "select eno from empl where eno=" & cint(txteno.text)
if not rs.eof then it exists -- msgbox
2) where did rs get set, your code doesn't specify?
|
|
|
|
|
is there any way to identify that the process is being close by task manager? (not in the application tab but in the process tab)
im using the formclosed event of the form but it doest work..
Private Sub frmMain_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Select Case e.CloseReason
Case CloseReason.ApplicationExitCall
MsgBox("Notify")
Case CloseReason.FormOwnerClosing
MsgBox("Notify")
Case CloseReason.MdiFormClosing
MsgBox("Notify")
Case CloseReason.None
MsgBox("Notify")
Case CloseReason.TaskManagerClosing
MsgBox("Notify")
Case CloseReason.UserClosing
MsgBox("Notify")
Case CloseReason.WindowsShutDown
MsgBox("Notify")
End Select
but it doesnt work when i closed the form in process tab(Task Manager)..
-- modified at 1:57 Thursday 14th December, 2006
|
|
|
|
|
There are a few different methods TaskManager TRIES on the Applications tab before doing the brute force "halt execution and free the memory" method. This last-ditch method is what the Processes tab uses when it "kills" a process. It isn't detectable by your code since your process ceases to execute when TaskManager obliterates the Process using this method.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
No, there isn't. You code STOPS executing, immediately. You don't have any way of detecting this if your no longer running.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi
I'm using vb.net 2005
I want to use treeview to view the table as a tree for expample :
id Name Parent
1 A1
2 B1
11 AA 1
23 BC 2
112 AcA 11
... etc
how can i make the treeview view the table as a tree
please every one try to help me to give me an example project
jooooo
|
|
|
|
|
id::::Name::::Parent
1 :::::A1 ::::
2 :::::B1 ::::
11:::::AA :::: 1
23:::::BC :::: 2
112::::AcA :::: 11
No one want to help me , or give me any web site that i can find the asnswer there
jooooo
|
|
|
|
|
Does anyone know how to delete a line within a txt file. I am trying to clean up a file that has unnecessary lines.
Any advice would help!
jds1207
|
|
|
|
|
You need to read the file into memory, remove the lines, and overwrite the file. You can't just delete a line from a file.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Do you have any sample code?
|
|
|
|
|
File.ReadAllText and File.WriteAllText ( from memory ) will let you read and write an entire file. The System.IO.File class has static methods to do it, for sure. And, the My shortcut in VB offers this stuff as well My.FileSystem, I think.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
But is there a way to get rid of a line in the file through code?
|
|
|
|
|
No. There is a way to read a file, and a way to overwrite a file. There is no way to select a line in a file and delete it. You need to read in the whole file, manipulate it, and over write it. as I said.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I have created a window service which accesses a folder on a seperate system and writes a file into it.
Everyone has been granted access on that folder
Now when i install service with user account it is able to create file into it,
but when i install service with either local system,local service or network service it is anot able to write file into it. it says "Access denied" to that folder.
Is there a way that i can write file into that folder with either local system,local service or network service.
Since i have tried with all possible right granted to that folder.
|
|
|
|
|
"everyone" does not include IUSR/IWAM/ASP.NET
try giving asp.net user write access to that folder (if it still fails try iusr/iwam also)
|
|
|
|
|
I have a window service which is accessing a shared folder on another server.
how does ASP.Net user will solve this problem as it is for IIS.
Also i want to access folder by installing services with "Local System" status
|
|
|
|
|
My apologies...I misread window service as webservice. you can use impersionation. have the window service logon as someone that does have access or falls under the group everyone when writing to the shared folder...
|
|
|
|
|
I have impersonated using WMI,
and while checking directory i use
system.io.Directory.Exists("Shared folder path")
it gives me exception "Access Denied" cause when i register service as Local System it uses Local system a/c to get access to the folder and that's why it says "Access Denied"
but when i Register it with User account it uses that a/c to get access which is in Everyone.
The work around is that register the service with User a/c but how to access folder with service registered "Local system"
|
|
|
|
|
sorry i explained the query wrong. i need to use a button to replace the selected item with the one above, and do the same with the one below. i suppose this code could be modified a bit but dont know how. can anyone help me please.
Select Previous:
ListBox1().SelectionMode = SelectionMode.One
If Me.ListBox1.SelectedIndex > 0 Then
Me.ListBox1.SelectedIndex = Me.ListBox1.SelectedIndex - 1
End If
Select Next:
ListBox1().SelectionMode = SelectionMode.One
If Me.ListBox1.SelectedIndex < Me.ListBox1.Items.Count - 1 Then
Me.ListBox1.SelectedIndex = Me.ListBox1.SelectedIndex + 1
End If
|
|
|
|
|
Stop spamming.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
oh i think i understand, you want the selected item on button press to have the same value as the next or previous item.
If that is the case:
Make sure your listbox selectionmode = selectionmode.multiextended
Select all:
ListBox1().SelectionMode = SelectionMode.MultiExtended<br />
For i As Integer = 0 To Me.ListBox1.Items.Count - 1<br />
Me.ListBox1.SetSelected(i, True)<br />
Next
Change current to same as previous:
ListBox1().SelectionMode = SelectionMode.One<br />
Dim Selected As Integer = Me.ListBox1.SelectedIndex<br />
Dim newItem As String<br />
<br />
If Me.ListBox1.SelectedIndex > 0 Then<br />
newItem = Me.ListBox1.Items.Item(Selected - 1)<br />
Me.ListBox1.Items.RemoveAt(Selected)<br />
Me.ListBox1.Items.Insert(Selected, newItem)<br />
Me.ListBox1.SelectedIndex = Selected<br />
End If
Change current to same as next:
ListBox1().SelectionMode = SelectionMode.One<br />
Dim Selected As Integer = Me.ListBox1.SelectedIndex<br />
Dim newItem As String<br />
<br />
If Me.ListBox1.SelectedIndex < Me.ListBox1.Items.Count - 1 Then<br />
newItem = Me.ListBox1.Items.Item(Selected + 1)<br />
Me.ListBox1.Items.RemoveAt(Selected)<br />
Me.ListBox1.Items.Insert(Selected, newItem)<br />
Me.ListBox1.SelectedIndex = Selected<br />
End If
Posted by The ANZAC
|
|
|
|
|
I want to be able to click only on the childs and not the roots in a treeview. Is this possible and if it is can somebody please explain to me how to do it. Thank You!
|
|
|
|
|
If you click only on child nodes how will you ever be able to use the expand/collapse feature of treeviews? This is one of the advantages of using a treeview.
Not saying it's impossible, just think it's a bit weird. What exactly are you trying to do? Maybe I can help.
|
|
|
|
|
I have a datagridview in which I have a list of items some of which are priced in Dollars and some in sterling is there any way to format the columns accordingly.
I have a second column which can be used to pick the currency up from eg.
Roller skates 22.40 USD
Fishing Rod 34 GBP
what I would like to see is
Roller skates $22.40 USD
Fishing Rod £34.00 GBP
I can format the Whole column if they are the same currency using
.CellTemplate.Style.Format = "C2"
I assume this picks up the default currency? If I can alter the currency Symbol for an individual cell then I'm Ok.
Thanks for any help
|
|
|
|
|
Hi
I'm populating an xml file from a dataset. There are some columns that sometimes don't have a value. The problem is that those column names don't appear in the xml file when they don't have a value. How do I get those columns to still appear in the xml file and not be ignored?
Thanks,
RainFox - cunning, with some cloudy clueless moments, yet cool and fresh
|
|
|
|