|
Thanks for help I will see what comes out of it.
Well I wanted to ask you how can I make this error image to appear in case there is no such picture file in the path folder.
|
|
|
|
|
BOREC wrote: how can I make this error image to appear in case there is no such picture file in the path folder
Put the regular code in the try part of a try-catch, and signal any problem in the catch
part, maybe by setting PictureBox.Image=someErrorPicture (which could fail as well unless
you use an embedded image resource...).
|
|
|
|
|
Hello,
I am a newby to Visual Basic.. I have been having some problems with adding my data in my program. I am using Vb2005 and trying to use sotored procedure but h have error on run time
message error : No mapping exists from object type System.Windows.Forms.TextBox to a known managed provider native type
This is what I have so far :
Dim con As New System.Data.SqlClient.SqlConnection("Data Source=.;Initial Catalog=School;Integrated Security=True")
Dim com As New System.Data.SqlClient.SqlCommand("proce_school_info", con)
com.CommandType = CommandType.StoredProcedure
com.Parameters.AddWithValue("@School_NameAr", Me.textBox1.Text)
com.Parameters.AddWithValue("@School_NameEn", Me.textBox2.Text)
com.Parameters.AddWithValue("@School_Edara ", Me.textBox3.Text)
com.Parameters.AddWithValue("@School_Address", Me.textBox4)
com.Parameters.AddWithValue("@School_City", Me.textBox5)
com.Parameters.AddWithValue("@School_Nation ", Me.textBox6.Text)
com.Parameters.AddWithValue("@School_Phone", CType(Me.textBox7.Text, Integer))
com.Parameters.AddWithValue("@School_Fax", CType(Me.textBox8.Text, Integer))
com.Parameters.AddWithValue("@School_Email", Me.textBox9.Text)
'com.Parameters.AddWithValue("@School_City", Me.textBox8.Text)
com.Parameters.AddWithValue("@School_Country", Me.textBox10.Text)
com.Parameters.AddWithValue("@School_Abbrev", Me.textBox11.Text)
com.Parameters.AddWithValue("@School_FirstYear", Me.textBox12.Text)
con.Open()
com.ExecuteNonQuery()
con.Close()
Ahmed hassan
|
|
|
|
|
hassanasp wrote: com.Parameters.AddWithValue("@School_NameAr", Me.textBox1.Text)
com.Parameters.AddWithValue("@School_NameEn", Me.textBox2.Text)
com.Parameters.AddWithValue("@School_Edara ", Me.textBox3.Text)
com.Parameters.AddWithValue("@School_Address", Me.textBox4)
com.Parameters.AddWithValue("@School_City", Me.textBox5)
com.Parameters.AddWithValue("@School_Nation ", Me.textBox6.Text)
com.Parameters.AddWithValue("@School_Phone", CType(Me.textBox7.Text, Integer))
com.Parameters.AddWithValue("@School_Fax", CType(Me.textBox8.Text, Integer))
com.Parameters.AddWithValue("@School_Email", Me.textBox9.Text)
'com.Parameters.AddWithValue("@School_City", Me.textBox8.Text)
com.Parameters.AddWithValue("@School_Country", Me.textBox10.Text)
com.Parameters.AddWithValue("@School_Abbrev", Me.textBox11.Text)
com.Parameters.AddWithValue("@School_FirstYear", Me.textBox12.Text)
I've bolded two lines above. You will notice that the lines in bold are missing something that the other lines have. That is the .Text property.
And, by the way, naming your text boxes as textBox1, textBox2, etc. won't win you any friends. Please give them better names because the person that comes after you to maintain your code will curse you for it. And if you end up having to maintain the code you'll end up cursing yourself.
|
|
|
|
|
I notice that some .net programs do this -- allowing tab pages to float and dock in other places. Is this done with a 3rd party application, or can I do it through normal .net code? Perhaps this will be a new feature in 2008?
Thanks
|
|
|
|
|
I have been using a FOR loop to loop through the column indexes in an MS Access table and create a textbox and corresponding label on a form for each column. I am incrementing an index to step through all the columns in the Columns collection for the table. I had expected that looping through the columns this way would loop through the columns from left to right in the table (or possibly loop through in the order that the columns were created.) Unfortunately it seems that the index order is more random than that.
My question is: How can I change the column indexes to my liking OR loop through the columns from left to right using VB.Net? My original code is posted below.
Thanks, friends.
- Craig
DataSetColumnUpperBound = EventsNotifications.Ds_BorrowerGenInfo.Borrower_General_Info.Columns.Count - 1
'Dynamically create textboxes and labels
For TBindex = 2 To DataSetColumnUpperBound
Dim NewTB As New System.Windows.Forms.TextBox
Dim NewLbl As New System.Windows.Forms.Label
TBName = "Textbox" & TBindex
LblName = "Label" & TBindex
Me.Controls.Add(NewTB)
Me.Controls.Add(NewLbl)
NewTB.Name = TBName
NewLbl.Name = LblName
NewTB.Enabled = True
NewLbl.Enabled = True
NewTB.Visible = True
NewLbl.Visible = True
NewTB.Height = 20
NewLbl.Height = 20
NewTB.Width = 420
NewLbl.Width = 420
NewTB.Top = 85 + ((TBindex - 2) * 45)
NewLbl.Top = 70 + ((TBindex - 2) * 45)
NewTB.Left = 20
NewLbl.Left = 20
NewLbl.BackColor = Color.Transparent
NewTB.Text = EventsNotifications.Ds_BorrowerGenInfo.Borrower_General_Info.Rows(0).Item(TBindex).ToString
NewLbl.Text = EventsNotifications.Ds_BorrowerGenInfo.Borrower_General_Info.Columns(TBindex).ColumnName.ToString & ":"
NewLbl.Font = New Font(NewLbl.Font, _
NewLbl.Font.Style Or FontStyle.Bold)
AddHandler NewTB.Enter, AddressOf WhichTextBox
NewTB.ContextMenuStrip = ContextMenuStrip1
Next TBindex
"That rug really tied the room together."
modified on Tuesday, December 18, 2007 12:16:42 PM
|
|
|
|
|
Hi…
I am not sure how much will this help you, but I think there is an easier way then to change the index without going into VB.net codes…
Just change the order of fields to the way you want in the database query
Like…
Select a, b, c from tab1
To
Select c, b, a from tab1
Good luck
Nishkarsh
|
|
|
|
|
Thank you, Nishkarsh. You are absolutely right. Once I changed the SQL query it all fell into place.
"That rug really tied the room together."
|
|
|
|
|
I have written a small Windows service that consists of a Windows.Forms.Timer control.
I have set the Interval property to 30000 and also tried 100. The Tick event of the timer never seems to fire.
Protected Overrides Sub OnStart(ByVal args() As String)<br />
backupTimer.Interval = 30000<br />
backupTimer.Start()<br />
End Sub<br />
<br />
Protected Overrides Sub OnStop()<br />
backupTimer.Stop()<br />
End Sub<br />
<br />
Private Sub backupTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles backupTimer.Tick<br />
backupTimer.Stop()<br />
'Other code here<br />
backupTimer.Start()<br />
End Sub
Any help appreciated
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Hi
You should use System.Timers.Timer or System.Threading.Timer instead of the System.Windows.Forms.Timer .
The System.Windows.Forms.Timer requires a MessageLoop in order to work. and the others will work without a MessageLoop
greets
M@u
|
|
|
|
|
Here is basically the only way I have been able to get the timer to fire correctly in Windows Service:
Class level variable:
Private coTimer As New System.Timers.Timer(10000)
Add a handler in "OnStart" event to the timer's elapsed event and enable it:
<br />
Protected Overrides Sub OnStart(ByVal args() As String)<br />
AddHandler coTimer.Elapsed, AddressOf coTimer_Elapsed<br />
coTimer.Enabled = True<br />
EventLog.WriteEntry("MyService Started")<br />
End Sub
Subroutine to take advantage of the timer:
<br />
Private Sub coTimer_Elapsed(ByVal pSender As Object, ByVal pArgs As System.Timers.ElapsedEventArgs)<br />
EventLog.WriteEntry("Timer Fired!")<br />
End Sub
That should do the job for you.
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
hi all
thnaks for previous reply
One more thing I want to ask u guys.it must be silly que.Actually I am working in vb.net2003
in my one application breakpoits works properly.but in another application ,when i debug application one quemark appear on break pt.& it does not work at all.I do't know wt happend.Can any one help me.
thanks in advance
poonam
|
|
|
|
|
Hi Poonam,
I tried to reproduce the said behavior at my end. Unfortunately, I was not able to do so. I would suggest you to please try repairing the Visual Studio, it might be possible that IDE has been corrupted.
I hope this helps.
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
hi Poonam,
Please check you are not debugging the application in Realease mode. If you want to debug an application it must be running in debug mode and not in Release mode.
Regards,
Nilesh Hapse
|
|
|
|
|
hi nilesh
plz tell me hw i know application running in debug or release mode.& hw i solve the problem.
thanks for reply
poonam
|
|
|
|
|
Hii,
Presently , i am using a property in propertygrid of type Image class to add an image to picturebox at runtime .It is showing the image . No
Problem .
Now , i am not able to get the selected image path as string . I have to save the image path, but it is returning
If Not CType(ctr, PictureBox).Image Is Nothing Then<br />
Dim filePath As String = CType(ctr, PictureBox).Image.ToString()<br />
as "System.Drawing.Bitmap"
if i use imagelocation it is returning as null exception. ' i dont want to use this one
Here, i want to get like this "C:\Documents and Settings\sriram\My Documents\My Pictures\cp.Jpg"
Thanks ,
DVS
|
|
|
|
|
Hello,
You can use the ImageLocation property to retrieve the image path. However, you will have to
use the load() method of the Picture box to get the image in the box.
Lets say you have one picture box and two buttons. First button is used to browse for images and
second button is used to retrieve the image path. In this case, you can try the following code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
<br />
Dim ofd As New OpenFileDialog<br />
ofd.Filter = "JPG|*.jpg|BMP|*.BMP|All Files|*.*"<br />
<br />
Dim result As DialogResult<br />
result = ofd.ShowDialog<br />
<br />
If result = Windows.Forms.DialogResult.OK Then<br />
<br />
Me.PictureBox1.Load(ofd.FileName)<br />
<br />
End If<br />
<br />
End Sub<br />
<br />
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click<br />
<br />
MsgBox(Me.PictureBox1.ImageLocation)<br />
<br />
<br />
End Sub
I hope this will help. If you have any doubts, please reply to this thread.
Regards,
Allen
Allen Smith
Software Engineer
ComponentOne LLC
www.componentone.com
|
|
|
|
|
Well Thanks For the reply ,
I dont want in this way . I want in a way like if we select an image property of image type in propertygrid ,then we can select an image at any location and if we click button ok , the image wil be loaded in to the picturebox .In propertygrid it is showing as "System.drawimg.bitmap" without showing the image path .
Or in any way i want the file path . Actually i didnt find any method to get the selected image path in VS2005 or 2003 .Like the one in File Dialog ("FileName")
I want here the file path .
I Really needed it
DVS
|
|
|
|
|
hi,
is there tool do as button.preformclick in label ?
|
|
|
|
|
break_day wrote: is there tool do as button.preformclick in label ?
???
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.
|
|
|
|
|
No, there is no Label.PerformRead().
|
|
|
|
|
Although your question does invite ridicule, there is a way to do what you want.
1. Put the code that you want to run when you click the label in a separate sub.
2. call that sub in the click event of your label.
3. also call that sub in the VisibleChanged event of your label:
<br />
Private Sub Label1_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.VisibleChanged<br />
If Label1.Visible = True Then YourSub()<br />
End Sub
4. where you would have called label1.performclick (if it existed, which it doesn't), instead use:
<br />
Label1.Visible = false<br />
Label1.Visible = True<br />
A complete example:
<br />
Private Sub Label1_textChange()<br />
Label1.Text += "bla"<br />
End Sub<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Label1.Visible = False<br />
Label1.Visible = True<br />
End Sub<br />
<br />
Private Sub Label1_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.VisibleChanged<br />
If Label1.Visible = True Then Label1_textChange()<br />
End Sub<br />
P.S. the VisibleChanged event will also fire when your form loads, so you may want to clear it in the Form's Load event:
<br />
Private Sub YourForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
Label1.Text = ""<br />
End Sub<br />
Good luck,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Good morning all
i have a strange situation here,am using a thread to hide my splash screen and after the Splash screen i Display my login screen, and after the i validate the credentials against the database, i need to Close the login Box and show the Main Form(MDI),ok that works fine, but the Login box et stucked at my screen. here is the code where it supposed to close
Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click
Dim frmmain As New frmmain
Dim frmlogin As New frmLogin
Dim strusername = CStr(txtusername.Text.Trim)
Dim strPassword = CStr(txtpassword.Text.Trim)
Dim obj As New Admin_BLL.Clients
Dim bl As Boolean
Try
bl = obj.loginBLL(strusername, strPassword)
If bl = True Then
frmlogin.Close()
frmmain.Show()
Else
bl = False
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
.
Please tell me whats wrong with code.
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
|
|
|
|
|
Vuyiswa wrote: CStr(txtusername.Text.Trim)
This is a waste of time, txtusername.text.trim is already a string
Vuyiswa wrote: Dim frmmain As New frmmain
This is your new 'main' form
Vuyiswa wrote: Dim frmlogin As New frmLogin
and this is a new 'login' form
Vuyiswa wrote: frmlogin.Close() frmmain.Show()
I'm not sure why showing a main form modelessly, which then immediately goes out of scope, works. But, creating a new login form and then closing it, will do nothing for the other login instance that is already visible elsewhere.
The use of CStr makes me think you've used VB6. You should avoid VB6 constructs, they are nasty, and you should buy a book on OO to help you learn your way past these sort of issues.
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 )
|
|
|
|
|
Good Morning Chris
Go Easy on i do buy books. i will not Convert string to String again, i know that a textbox, is already a string, so i trying to fool proof it, but thanks for the advice about that.
Thanks for the Advice
Thanks
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
|
|
|
|
|