|
right now i'm trying to add data to a database. i think i'm almost their but get this error message
"Property access must assign to the property or use its value"
this is what code i got
Imports System.Data.OleDb
Public Class Cust
Inherits System.Windows.Forms.Form
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim icount As Integer
Dim str As String
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\PCBank.mdb;")
cn.Open()
str = "insert into customer values(" & CInt(tbID.Text) & ",'" & tbSur.Text & "','" &
tbFor.Text & "')"
'string stores the command and CInt is used to convert number to string
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery
MessageBox.Show(icount)
'displays number of records inserted
Catch
End Try
cn.Close()
End Sub
End Class
can anybody enliten me?
|
|
|
|
|
I might have the answer you seek, but I haven't looked in any depth at this problem. It may be something to do with the insert statement and/or the customer table. Does the table only have 3 columns: an id, a surname and a forename? Is the id column auto-generated (or whatever the term is in MS Access)? Try naming the columns in your insert statement. I don't know what columns your customer table has but it might be something like this: insert into customer (id, surname, forename) values (99, 'Rogers', 'Dave') Dave
|
|
|
|
|
Hello!
It is quite bit intrique because I am creating 80 buttons in runtime and assigning a name with an incremental value such as myButton.Name = "GButton_" + I.toString. Therefore, each button has a different name.
Dim I as Int32
For I = 1 to 5
Dim myButton as New Button
myButton.Name = "GButton_" + I.toString
me.controls.add(myButton)
Next
How can I reach the GButton_3.backcolor property somewhere in code (out of the procedure where I create the buttons). Would it be possible to define the name and set its property? Is there a way to use such as EVAL function to perform something eval( "GButton_" + I.tostring + ".backcolor=" + setcolor) THANK YOU.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Why throw away the reference to the button that you actually have, and then try to get it again?
Just store the references in an array so that you easily can access the buttons later.
---
single minded; short sighted; long gone;
|
|
|
|
|
hi,
it is easier as you think
either you iterate the "Controls" collection of the Form:
For Each ctl as Control In Me.Controls
If ctl.Name = "GButton2" Then
ctl.Backcolor ....
Exit For
End If
Next
or you just call the following:
Me.Controls("GButton2").Basckcolor ...
storing it in an array is not necessary, because the added controls are already stored in an collection (Me.Controls)
solidIT.de - under construction
Components for Microsoft .Net
audittrail, objectcomparer, deepcopy and much more ...
|
|
|
|
|
Thank you! I will try it...
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
testy_proconsul wrote: it is easier as you think
It's even easier than you think.
testy_proconsul wrote: storing it in an array is not necessary, because the added controls are already stored in an collection (Me.Controls)
Yes, of course it's not necessary, but it's the easiest and fastest way to get the reference.
---
single minded; short sighted; long gone;
|
|
|
|
|
"i dont wanted to cut you short" ... guffa. and sorry for my bad english
but opinion is to keep the overhead as small as possible and to use predefined functionality. generally this keeps overview, readability and conformity ...
solidIT.de - under construction
Components for Microsoft .Net
audittrail, objectcomparer, deepcopy and much more ...
|
|
|
|
|
Can anyone help me or point me in the right direction.
I am running VB.Net 2003 and have a form that I wish to print. For argument's sake, the form has 4 fields e.g. txtField1.text, txtField2.text, txtField3.text and txtField4.text
Each field has a value in it. How can I print this form or fields direct to my printer. The reason I want to do it this way is that each field has a complex calcualation to get to its value. Another way is how could I make a text file with these values and put onto a crystal report.
I hope this make sense.
|
|
|
|
|
You might be able to use this control[^], although it is written in VB.Net 2005 so you may have to do some changes...?
|
|
|
|
|
Hello!
In shown sample below, I have a loop what ceates instances of a button. What I want to know is which one gets clicked in runtime? Thank you.
<code>
Public Sub AddButtons()
For I = 1 to 10
Dim myButton as new Button
myButton.text = "Hello"
me.Controls.Add(myButton)
AddHandler myButton.click, AddressOf myButtonEvent
Next
End Sub
' Here is the event handler for the button
Private sub myButtonEvent (Byval Sender as Object, e as EventArg)
'Here I want to know which button has been clicked because there are 10
'buttons on the form.
End Sub
</code>
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
in your button event:
dim b as Button<br />
b= Ctype(sender,Button)
the b will be the button that was clicked.
If you are wanting to run different code depending on what button was clicked you can check for the name, or assign a value to the tag property and use that for identification.
Hope that helps
-- modified at 11:34 Tuesday 13th March, 2007
|
|
|
|
|
Yep! it is working now. Thank you very much.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
You would want to set the button id value.
Something like myButton.Id = "btn"+I.ToString();
Then in the event
CType(Sender, Button).Id to figure out which button.
Hope that helps.
Ben
|
|
|
|
|
Private Sub AddButtons
Dim btn As Button
For i As Integer = 1 To 10
btn = New Button()
btn.Name = "GBtn" & i.ToString()
btn.Text = "Push " & i.ToString()
btn.Top = btn.Height * i
AddHandler btn.Click, AddressOf GBtn_Click
Me.Controls.Add(btn)
Next
End Sub
Private Sub GBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
MessageBox.Show(sender.ToString())
Select Case DirectCast(sender, Button).Name
Case "GBtn1"
Case "GBtn2"
End Select
End Sub
solidIT.de - under construction
Components for Microsoft .Net
audittrail, objectcomparer, deepcopy and much more ...
|
|
|
|
|
help me with the towers of hanoi program.use recursive tower method. the parameters are 1.number of disks tobe moved
2.disks on initial peg
3.peg to which this stack of disks is tobe moved
4. peg tobeused as a temporary holding area
|
|
|
|
|
There is an article about this here [^] on Code Project. Do a search before asking for homework help.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
You have three questions posted and they are all obviously homework. Work on it and if you get stuck then ask your question.
_________________________________________
You can't fix stupid, but you can medicate crazy.
|
|
|
|
|
Wow I give him a link from CP and he reposts 2 days later. *Throws hands up in despair*
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
With VisualStudio.Net, i'm using an installer class with a custom action
on my setup project to ask the user a serial number. A "Textboxes"
dialog on the "user interface" provides the serial number string to an
overrided version of then install procedure, inside my installer class.
My problem is that the install sub is able to verify the serial number
entered, but then i can't stop/cancel the installation procedure.
|
|
|
|
|
can anyone please tell me how i can input data into 3 seperate textboxes on a form, then press a button and for that data to be placed in 3 fields on a database.
thanks
|
|
|
|
|
See MSDN for ADO.NET .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
i set the backcolor of label to Transparent and it's parent to picturebox but nothing appear in runtime ??? (picturebox exist under the label)
|
|
|
|
|
Why are you putting a label OVER the picturebox? Are you sure that the picturebox is actually linked to an image and showing it?
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
Because i wanna make an image button user control component. Yes picture box linked to an image and i'm working with VB.Net 2005 platform.
-- modified at 13:32 Tuesday 13th March, 2007
|
|
|
|