|
hellow to all ...
how can i call Events in vb.net ?
i wanna call the painting event of a picturebox every time i click a button , to redraw something ...
thx for anyhelp ...
|
|
|
|
|
You dim the picture box adding the 'withevents' keyword.
You create the event eg public event eventname
You add 'handles ButtonName_Click' to the event you created, this will tell vb that when you click that button, it must run this event.
There are 10 types of people in this world, those who understand binary and those who don't!
|
|
|
|
|
i have an enumeration (Yes/No) , and the according value are 1/0 when i store them in the database.
when i retrieve the data from BD and display it on a datagrid they appear 1s and 0s but i want them to appear Yes No ??
thank you all
Tamimi - Code
|
|
|
|
|
Your enums have those values ? If so, I'd think you could cast those numbers to an instance of the enum and call ToString on it.
However, for those two values, it's just as easy to write the code to convert them to strings.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
this my enum
Public Enum EnumYesNo
Yes = 1
No = 0
End Enum
so i will store 1 when i do objRow("approve") = EnumYesNo.Yes .
when i retrive the row i will get 1(displayed in the grid) for the column "approve", how can i change it to "Yes".
this is a win application
thank you
Tamimi - Code
|
|
|
|
|
One obvious way would be to add a column to your stored proc that contains the display string you want and bind to that value instead.
Any other solution would involve modifying the data row by row.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
thank you ... i was think about direct way to do that.;)
but i will add new colunm.....
Tamimi - Code
|
|
|
|
|
****This is my component coding****
Public Class DepartmentValidator
Inherits System.ComponentModel.Component
Private empid As String
Private pwd As String
Public Property EmployeeID() As String
Get
Return empid
End Get
Set(ByVal Employeeid As String)
empid = Employeeid
End Set
End Property
Public Property Password() As String
Get
Return pwd
End Get
Set(ByVal Password As String)
pwd = Password
End Set
End Property
Public Function Validate() As Boolean
Dim em As String
Dim pw As String
Dim conn As New OleDb.OleDbConnection("provider=SQLOLEDB;User ID=saassword=;Trusted_Connection=yes;Initial Catalog=employees;data source=localhost")
Try
conn.Open()
Catch ex As Exception
MsgBox("There have problem in connecting to database")
End Try
Dim selectemp As OleDb.OleDbCommand = New OleDb.OleDbCommand("select cempid,cpassword from employees where cEmpID=?", conn)
Dim dr As OleDb.OleDbDataReader
dr = selectemp.ExecuteReader()
Do While dr.Read = True
em = dr.GetString(0)
pw = dr.GetString(12)
If (em = empid And pw = pwd) Then
Return True
Else
Return False
End If
Loop
dr.Close()
*****This is user validation form coding***
Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click
Dim validator As DepartmentValidator
validator = New DepartmentValidator
validator.EmployeeID = txtempid.Text
validator.Password = txtpwd.Text
validator.Validate()
If validator.Validate = True Then
MsgBox("Valid User")
Else
MsgBox("Invalid user")
End If
when i'm run this and type employee id and password there display the error in my component codings. Error is like below
An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: ExecuteReader requires an open and available Connection. The connection's current state is Closed.
Could someone help solve 4 this problem pls,if need my coding also ask frm me
Thank You
-- modified at 1:06 Wednesday 26th July, 2006
|
|
|
|
|
maybe Youre connection String isn't True
Check you're Connection string
MHf
|
|
|
|
|
hi
i have virtually no vb experience so i hope i can explain this clearly.
i have made a interface that i wont to copy a players name from a server browser listview "the all seeing eye"
i need a textbox to autofill with the players name from a listview once i start inputting a name.
getting the textbox to autofill from the name listview is not happining.
can anybody help me with this.
the reason i am undertaking this is to help us adminasta a game server which is being overrun with game hackers.
i wont to be able to copy a players name and paste in a guid search engine to determine if they have any hacking convictions listed against them.
cheers
toe
-- modified at 1:43 Friday 28th July, 2006
|
|
|
|
|
Textboxes do not support autofill, you will need to find or write a custom control to do this.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
vb2005 text and combobox's do autofill but gettin them to fill from another program is the problem.
in the controls properties down the bottom u have all the autocomplete properties
cheers
toe
|
|
|
|
|
bump
|
|
|
|
|
How can i enumerate tray icon? I want to get other program' tray icon
|
|
|
|
|
I need some help creating an MS-Word counter macro as I'm not well versed in Visual Basic. I am trying to find a repeating XML tag pattern in an MS-Word file as shown below:
<subunit>
any text . . .
</subunit>
What I need the macro to do is to attach a number to the tag and each time the tag is found, the number should increment by 1.
See my desired output:
<subunit_1>
any text . . .
</subunit_1>
<p>
<subunit_2>
any text . . .
</subunit_2>
<p>
<subunit_3>
any text . . .
</subunit_3>
Can such a macro be created in Word? I do have some experience editing macros in the VB editor but very limited.
I might add that I already have a macro that duplicates an XML tag each time I run the macro but without the incrementing. Should I try to edit this current macro to get my desired output?
Thanks
Harold
-- modified at 0:05 Wednesday 26th July, 2006
|
|
|
|
|
Hi,
My application requires a date/time field to be set to display a blank field by default, unless modified by the user. Right now it displays the current date and, if not changed by the user, on saving the record that date is passed to the database. Could somebody please let me know how this is done?
Thanks in advance.
Larry
|
|
|
|
|
Hi
Whats the control you are using in the user interface?
Chandra
|
|
|
|
|
I have one last VB.NET newbie question for the masses and then I promise to make my way.
I have a list box with myriad entries and I would like to know when the user right-clicks a specific item in the list box so I can display a right-click menu with a couple options they can perform on that entry. How is this done in VB.NET?
Thank you!
|
|
|
|
|
You will need to add a context menu to the form.
<br />
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown<br />
If e.Button = MouseButtons.Right Then<br />
ContextMenu1.Show(Me.ListBox1, New System.Drawing.Point(e.X, e.Y))<br />
End If<br />
End Sub<br />
Mike Lasseter
|
|
|
|
|
I wrote a scipt that takes an Access database and imports it to SQL Server. The Access db has over 1 million records in it. The script works, but around halfway through adding the records I get a "page cannot be displayed" error. It is strange because there is nothing in my script that tells it to change pages. This error occurs during the WHILE loop. If i look at my SQL db, i can see that the script is still running and adding records even though this error page appears. I think it may be some sort of server setting, but have not been able to figure it out. I need to redirect the user later in the script after this import completes, so I need to get this fixed. Here is my code:
<br />
Sub Cat1_Import()<br />
Dim startTime = Timer<br />
Dim AccessConn As OleDbConnection<br />
Dim AccessCmd As OleDbCommand<br />
Dim RecSet As OleDbDataReader<br />
Dim SqlString As String = "Data Source=mysource;Initial Catalog=mycatalog;Pooling=True;Min Pool Size=100;Max Pool Size=200;User ID=user;Password=pass"<br />
Dim SqlConn As SqlConnection<br />
Dim SqlCmd As SqlCommand<br />
Dim SqlRecSet As SqlDataReader<br />
Dim UpdateSql As String<br />
Dim SelectSql As String = "SELECT * FROM [Equipment Contract Pricing]"<br />
<br />
'connect to Access db<br />
AccessConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=path-to-my-db\Equipment.mdb")<br />
AccessConn.Open()<br />
AccessCmd = New OleDbCommand("SELECT * FROM [Equipment Contract Pricing]", AccessConn)<br />
RecSet = AccessCmd.ExecuteReader()<br />
<br />
'connect to sql server<br />
SqlConn = New SqlConnection(SqlString)<br />
SqlConn.Open()<br />
<br />
'loop through access db records to insert each record into Sql Server db<br />
While RecSet.Read()<br />
UpdateSql = "INSERT INTO [Equipment Contract Pricing] (CLIN, Offeror_ID, Product, ID_Number, Description, Specifications, Standards, ISO9000, Manufacturer, Model_No, Cat_Code, Sale_Area, Purch_Price, Price_Unit, YR, Last_Update_P) Values "<br />
UpdateSql &= "('" & RecSet("CLIN") & "', '" & RecSet("Offeror_ID") & "', '" & Replace(RecSet("Product"), "'", "''") & "', '" & RecSet("ID_Number") & "', '" & Replace(RecSet("Description"), "'", "''") & "', '" & Replace(RecSet("Specifications"), "'", "''") & "', '" & RecSet("Standards") & "', '" & RecSet("ISO9000") & "'"<br />
UpdateSql &= ", '" & RecSet("Manufacturer") & "', '" & RecSet("Model_No") & "', '" & RecSet("Cat_Code") & "', '" & RecSet("Sale_Area") & "', convert(money,'" & RecSet("Purch_Price") & "'), '" & RecSet("Price_Unit") & "', '" & RecSet("YR") & "', '" & RecSet("Last_Update_P") & "')"<br />
SqlCmd = New SqlCommand(UpdateSql, SqlConn)<br />
SqlCmd.ExecuteNonQuery()<br />
End While<br />
<br />
SqlCmd = New SqlCommand(SelectSql, SqlConn)<br />
SqlRecSet = SqlCmd.ExecuteReader()<br />
If SqlRecSet.HasRows Then<br />
Session("import") = "Data successfully transferred."<br />
Else<br />
Session("import") = "Temporary table is still empty. There was an error importing the data."<br />
End If<br />
<br />
RecSet.Close()<br />
SqlRecSet.Close()<br />
AccessConn.Close()<br />
SqlConn.Close()<br />
<br />
Dim endTime, processTime, hrTime, minTime, secTime As Double<br />
endTime = Timer<br />
processTime = endTime - startTime<br />
hrTime = processTime / 3600<br />
minTime = processTime / 60<br />
secTime = Decimal.Remainder(processTime, 60)<br />
If secTime < 0 Then secTime = 0<br />
Session("time") = "Total Process Time: " & FormatNumber(hrTime, 0) & " hours, " & FormatNumber(minTime, 0) & " minutes, " & FormatNumber(secTime, 0) & " seconds"<br />
<br />
End Sub<br />
Anyone have any iseas why this is happening?
Thanks,
Mike
|
|
|
|
|
I just wanted to add to this post. I put a timer on the page and this error occurs at the 1 hour mark every time. I am pretty sure this is a server issue. Maybe there is a setting in IIS I am overlooking. Any ideas?
|
|
|
|
|
Hello!
I posted a bit ago with a question about a syntax error in a seemingly-flawless SQL string but now I'm back with what is hopefully a simpler problem:
In my program, record (tuples) in a database are represented as items in a list box. The user can select any item they wish from the list box and have all the information about that entry readily displayed to the form - this part is working just fine.
What isn't working is record deletion. Although the deletion itself is working (in that it does, in fact, delete the selected record), it does not update the primary key (an ID # in this case) at all thus after deleting a few random records I am left with a rather unorderly database.
I have tried manually updating the ID via an SQL UPDATE statement as follows:
oleCommand.CommandText = "UPDATE tblEvents (ID) VALUES (" + nCount + ")"
Where:
oleCommand = my OleDbCommand object
tblEvents = my table within the database I'm using
ID = the primary key of this table
nCount = a counter variable dually-used to step through a loop while setting the ID for each record.
Please let me know if oyu have any ideas and thank you in advance!
|
|
|
|
|
Hi
Is the ID field an AutoNumber?
|
|
|
|
|
I have tried both Autonumber as well as a regular Number and neither work. Currently, it is set for Autonumber
|
|
|
|
|
Hi
Is the SQL statement within the loop?
Chandra
|
|
|
|