|
I know it'll work. He just needs to rewrite his Case statements. I also hate getting the TypeOf over and over again until it finds the correct Case. I get it once, before the Select, then use then returned type in the rest of the code.
|
|
|
|
|
sorry - misunderstood your statement 'Select Case won't do this'.
question on a different subject. each control has an event "enabledchanged" is there a way to make this fire even if you give it the same value? Enabled=true / Enabled=true? Is there any other technique that can be done that doesn't envolve creating my own control wrapper to detect this?
Thanks for your time.
Nathan
|
|
|
|
|
nlarson11 wrote: each control has an event "enabledchanged" is there a way to make this fire even if you give it the same value? Enabled=true / Enabled=true?
No, it'll fire whenever the value actually changes.
nlarson11 wrote: Is there any other technique that can be done that doesn't envolve creating my own control wrapper to detect this?
Nope. You have to replace the Enabled property's Set method of the controls to get this to work. As it stands now, the Enable property code is this:
<DispId(-514), Localizable(True), SRCategory("CatBehavior"), SRDescription("ControlEnabledDescr")> _
Public Property Enabled As Boolean
Get
If Not Me.GetState(4) Then
Return False
End If
Return ((Me.ParentInternal Is Nothing) OrElse Me.ParentInternal.Enabled)
End Get
Set(ByVal value As Boolean)
Dim enabled As Boolean = Me.Enabled
Me.SetState(4, value)
If (enabled <> value) Then
If Not value Then
Me.SelectNextIfFocused
End If
Me.OnEnabledChanged(EventArgs.Empty)
End If
End Set
End Property
See the bolded If statement?? That's why the event won't fire if the value doesn't actually change. If the internal enabled variable is the same as the value passed in, the OnEnabledChanged method is never called, which is what raises the event.
Actually, the more I think about this, I'd ADD A NEW EVENT, possibly called EnabledSet , and raise it from the Set code in the Enabled property. I would NOT change the behavior of the existing EnabledChanged event.
|
|
|
|
|
|
I am working on SEO based project. In this project I need to find reciprocal website of other site. means here i need to find that the url site who wants to put their name on my site, then that site should also have my url address in thier site. so how can I find that whehter the requested site contains my url address or not. Please help me. Thanks in advance
|
|
|
|
|
|
He's posted the same thing in at least 4 forums.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Don't cross post. It is very rude.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
For a tableAdapter , vb.net usually create automatically the fill() function .But i want to create a fill(parameter1) function where parameter1 is a value that filter data (by a filed ) filled into dataset.How can i do this ?
Thank you !
|
|
|
|
|
You'd have to write your own method to do this. Although, you would normally call the method something like "GetSomethingBySomeValue", not Fill(value). Make the name of the method meaningful. The concept is called "self documenting code". The name of the method should tell you what it does.
You can use the designer to help you do this by right-clicking the table you want in the dataset designer, and clicking Add Query...
|
|
|
|
|
Hi
I am quite new to this and have made a web project written in vb. Now i want to make a installer for this program and have created a web setup project and a custom action for that project. The thing is that during the install ui i want to run som code when the "next button" is pushed during one of the dialogs. How do i do this?
Confused
|
|
|
|
|
The custom action needs to run an exe with your code in it, you can't inject code into an MSI.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Cant you run for example Orca to customize a button and make it call a external dll or in some other way make it run som code that way? What i need is when a user enters the database name that he wants to use with the web project the program should check if the db already exists before he continues so that he can change the name.
Confused
|
|
|
|
|
Dim DBPath As String
Dim ADOXcat As New ADOX.Catalog
Dim sCreateString As String
DBPath = System.Windows.Forms.Application.StartupPath()
sCreateString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & DBPath & "\New07ADB.accdb;Jet OLEDB:Database Password=admin;" 'for Access 2007
Try 'Create DB
ADOXcat.Create(sCreateString)
Catch ex As System.Runtime.InteropServices.COMException
'create DB failed
MsgBox(ex.Message(), MsgBoxStyle.Critical, "Failed to create database")
Finally
ADOXcat = Nothing
End Try
Dim ADOXtable As New ADOX.Table(), _
ADOXindex As New ADOX.Index(), _
Con As New ADODB.Connection()
Try 'connect and insert tables
Con.Open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & DBPath & "\New07ADB.accdb;Jet OLEDB:Database Password=admin;") 'for 2007
MsgBox(Con.Errors().Count.ToString()) 'Displays 0 Errors
MsgBox(Con.State.ToString()) 'Displays 1 representing an open connection
'Open the Catalog
ADOXcat.ActiveConnection = Con 'Object reference not set to an instance of an object.
I know this error usally gets generated when using a null object but if I receive no errors from opening the connection then 'Con' shouldnt be null right? Any help on this is greatly appreshated.
|
|
|
|
|
Your con is fine, it is the ADOXCat that is not instantiated!
Quote from Great Outdoors:
its a confident traveller who farts in India
|
|
|
|
|
--> which symmetric algorithm is efficient to encrypt video file and why?
--> how can i compress video file in dotNet environment?
J A Nasir K
|
|
|
|
|
1 - they all are, to one degree or another. XVid and DivX are good, but so is MPG.
2 - by using DirectX
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i try to add datepicker to datagrid but i can see it, way?
Private Sub dg2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dg2.MouseDown
dtp.Dock = DockStyle.Fill
dtp.Cursor = Cursors.Arrow
dtp.SendToBack()
hitTestGrid = dg2.HitTest(e.X, e.Y)
If hitTestGrid.Column = 5 Then
datagridtextBox.TextBox.Controls.Add(dtp)
dtp.BringToFront()
End If
datagridtextBox.TextBox.BackColor = Color.Black
End Sub
|
|
|
|
|
liat1234 wrote: datagridtextBox.TextBox.Controls.Add(dtp)
You can't add a datetimepicker to a textbox. You can't add any controls to a textbox, unless you are using WPF
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i try to update my data base but i get this error message
"the update command effected 0 of the expected 1 records"
the insertcommand is ok
my code is
Private Sub btnUPDT_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUPDT.Click
'--------------------------------
'INSERT NEW ROWS
'--------------------------------
cmd.InsertCommand = New OleDbCommand()
Dim pCust_name1 As New OleDbParameter("@name1", OleDbType.VarChar)
pCust_name1.SourceColumn = "name"
Dim pCust_pass1 As New OleDbParameter("@pass1", OleDbType.VarChar)
pCust_pass1.SourceColumn = "pass"
Dim pCust_meried1 As New OleDbParameter("@meried1", OleDbType.Boolean)
pCust_meried1.SourceColumn = "meried"
Dim pCust_city1 As New OleDbParameter("@city1", OleDbType.VarChar)
pCust_city1.SourceColumn = "city"
Dim pCust_borndate1 As New OleDbParameter("@borndate1", OleDbType.Date)
pCust_borndate1.SourceColumn = "borndate"
cmd.InsertCommand.Parameters.Add(pCust_name1)
cmd.InsertCommand.Parameters.Add(pCust_pass1)
cmd.InsertCommand.Parameters.Add(pCust_meried1)
cmd.InsertCommand.Parameters.Add(pCust_city1)
cmd.InsertCommand.Parameters.Add(pCust_borndate1)
cmd.InsertCommand.Connection = Conn
cmd.InsertCommand.CommandText = "INSERT INTO users " & _
"(name, pass, meried, city, borndate)" & _
"VALUES (@name1, @pass1, @meried, @city, @borndate)"
'------------------------------------------
'UPDATE ROW
'------------------------------------
cmd.UpdateCommand = New OleDbCommand()
Dim pCust_id As New OleDbParameter("@id", OleDbType.Integer)
pCust_id.SourceColumn = "id"
Dim pCust_name As New OleDbParameter("@name", OleDbType.VarChar)
pCust_name.SourceColumn = "name"
Dim pCust_pass As New OleDbParameter("@pass", OleDbType.VarChar)
pCust_pass.SourceColumn = "pass"
Dim pCust_meried As New OleDbParameter("@meried", OleDbType.Boolean)
pCust_meried.SourceColumn = "meried"
Dim pCust_city As New OleDbParameter("@city", OleDbType.VarChar)
pCust_city.SourceColumn = "city"
Dim pCust_borndate As New OleDbParameter("@borndate", OleDbType.VarChar)
pCust_borndate.SourceColumn = "borndate"
cmd.UpdateCommand.Parameters.Add(pCust_id)
cmd.UpdateCommand.Parameters.Add(pCust_name)
cmd.UpdateCommand.Parameters.Add(pCust_pass)
cmd.UpdateCommand.Parameters.Add(pCust_meried)
cmd.UpdateCommand.Parameters.Add(pCust_city)
cmd.UpdateCommand.Parameters.Add(pCust_borndate)
cmd.UpdateCommand.Connection = Conn
cmd.UpdateCommand.CommandText = " UPDATE users SET [name]= @name, [pass]= @pass, [meried]=@meried WHERE [id] =@id"
cmd.Update(ds1, "users")
MsgBox("update table ended")
End Sub
|
|
|
|
|
hi
your code is fine, you have made it complicate you. in this cases, please use a Procedure to insert a new record into the table to avoid Sql injection. and i dont know how you gonna update a datagrid like that. check this article on how to update a datagrid.
.
http://www.codeproject.com/useritems/N-Tier_Application_VB.asp[^]
Hope i helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
i wrote this code but always row index 0 is deleted
where i wrong????
Private Sub btnDel_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDel.Click
Dim i As Integer
Dim usrId As String
ds1.GetChanges()
i = dg2.CurrentRowIndex()
usrId = dg2.Item(i, 0)
'delete from dataset
ds1.Tables(0).Rows(i).Delete()
cmd.DeleteCommand = New OleDbCommand()
cmd.DeleteCommand.Connection = Conn
cmd.DeleteCommand.CommandText = "delete * from users where id =" & usrId
'delete from database
cmd.Update(ds1, "users")
End Sub
liat
|
|
|
|
|
liat1234 wrote: i = dg2.CurrentRowIndex()
The current row index must be 0. If you want to delete a different row, select the row you want to delete by setting this property.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
You may try to do this in the following manner.
Dim con As SqlConnection
Dim adap As SqlDataAdapter
Dim ds As New DataSet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
binddata()
End Sub
Dim i As Integer
Dim s As String
Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
i = DataGrid1.CurrentRowIndex
s = DataGrid1.Item(i, 0)
End Sub
Sub binddata()
Try
con = New SqlConnection("server=200.100.100.139;user id=sa;pwd=hello;database=pubs;")
con.Open()
adap = New SqlDataAdapter("select * from employee", con)
adap.Fill(ds)
DataGrid1.DataSource = ds.Tables(0)
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
con = New SqlConnection("server=200.100.100.139;user id=sa;pwd=hello;database=pubs;")
con.Open()
Dim cmd As New SqlCommand
cmd = New SqlCommand("delete from employee where emp_id='" & s & "'", con)
cmd.ExecuteNonQuery()
binddata()
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Sub
I hope this helps.
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hello every one...
I am developing a application in vb.net, i want the text in mask box to be selected when a user enters in it..
I was able to do the same with Vb6, i am not able to do in VB.net 2005 Express..
Is the same also possible with text box??
Regards
Nishkarsh
|
|
|
|