|
I want to do the following.
I have a tab control with 3 tab pages. When I click on the say tab 1, then a procedure automatically starts.
If I put the procedure in say, TabPage2_Click, then I have to physically click on the tab. What I am aiming for is that when I click the tabPage of the Tab Control, the procedure automatically runs.
I have been trying various ways using TabControl1.TabPages(1) but with no success. I know this must be a simply process and I am missing something out.
|
|
|
|
|
Have you tried combining all the tabpage handlers into one event handler?
See the "Handles" clause at the end of your TabPage_Click event handler. You can add a comma then the next object and event that this code will handle. When any of the classes in the Handles list fire's it's Click event, this handler will be called.
Public Sub TabPage_Click(...,...) Handles TabPage1.Click, TabPage2.Click, TabPage3.Click
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi
i am a bigginner to this vb.net.i have a problem in inserting data programiticaly(without using wizard or server explorer)from vb.net application to sql data table.whatever i am inserting through vb.net is not updating in the table. i have searched from 2 months for this.please anybody help for this?please give sample code for this, (another question is i am using combo box in the application how to insert that?)
thanking you.
|
|
|
|
|
You posted this very question an hour ago? Don't repost, it's very rude and it won't get your question answered any faster.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Could somebody tells me the way to create string/array math using visual basic? Thank You!
|
|
|
|
|
What do you mean by a "string/array math"? This doesn't make any sense at all, so we couldn't even begin to tell you anything useful.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
If you want to know about array of strings
Dim ArrayOfString(0 to 3) as String
Redim Preserver ArrayOfString(5)
ArrayOfString(0)="Put "
ArrayOfString(2)="What "
ArrayOfString(3)="You "
ArrayOfString(4)="to "
ArrayOfString(5)="Save."
Shoaib Nawaz
|
|
|
|
|
hi
i am a bigginner to this vb.net.i have a problem in inserting data programiticaly(without using wizard or server explorer)from vb.net application to sql data table.whatever i am inserting through vb.net is not updating in the table. i have searched from 2 months for this.please anybody help for this?please give sample code for this, (another question is i am using combo box in the application how to insert that?)
thanking you.
shyli
|
|
|
|
|
Without seeing your SQL update code, it's impossible to tell you what your doing wrong.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Imports System.Data.SqlClient
Imports System.Data.DataTable
Imports System.Data.DataRow
Public Class Form1
Inherits System.Windows.Forms.Form
Dim flag As Integer
Dim custid As String
Dim dr As DataRow
Dim dt As DataTable
Dim DS As New DataSet
Dim Conn As SqlConnection = New SqlConnection
Dim CMD As SqlCommand = New SqlCommand
Dim DA As SqlDataAdapter = New SqlDataAdapter
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Conn As SqlConnection = New SqlConnection("workstation Id=SHAily;packet size=4096;integrated security=SSPI; data source=SHAILY; PERSIST SECURITY INFO=FALSE;INITIAL CATALOG=customer")
Dim CMD As SqlCommand = New SqlCommand("select * from tablename ", Conn)
CMD.Connection = Conn
DA.SelectCommand = CMD
DA.Fill(DS, "details")
Textbox1.DataBindings.Add("Text", DS.Tables("tablename"), "CUSTID")
Combobox1.DataSource = DS.Tables("tablename ")
Combobox1.DisplayMember = " tablename "
Combobox1.ValueMember = "NAME"
Textbox2.DataBindings.Add("Text", DS.Tables("tablename “), "ADDRESS")
Textbox3.DataBindings.Add("Text", DS.Tables("tablename "), "PHONE")
Combobox2.DataSource = Ds.Tables("tablename ")
Combobox2.DisplayMember = " tablename "
Combobox2.ValueMember = "POBOX"
End Sub
Private Sub BTNADD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BNADD.Click
dt = DS.Tables("tablename ")
Textbox1.Text = ""
Combobox1.Text = ""
Textbox2.Text = ""
Textbox3.Text = ""
Combobox2.Text = ""
flag = 1
Dim ctr, len As Integer
Dim custidval As String
len = (dt.Rows.Count - 1)
dr = dt.Rows(len)
custid = dr("CUSTID")
custidval = Mid(custid, 2, 3)
ctr = CInt(custidval)
If ctr >= 1 And ctr < 9 Then
ctr = ctr + 1
Textbox1.Text = "C00" & ctr
ElseIf ctr >= 9 And ctr < 99 Then
ctr = ctr + 1
Textbox1.Text = "C0" & ctr
ElseIf ctr >= 99 Then
ctr = ctr + 1
Textbox1.Text = "C" & ctr
End If
Textbox1.Enabled = True
End Sub
Private Sub BtnSAVE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSAVE.Click
If flag = 1 Then
da.Fill(DS, " tablename ")
'Dim dt7 As New DataTable
'dt7 = DS7.Tables("tablename ")
'dr = dt7.NewRow()
'Dim i As Integer
'dr(0) = custid
'dr(1) = Combobox1.Text
' dr(2) = Textbox2.Text
'dr(3) = Textbox3.Text
'dr(4) = Combobox2.Text
' dt7.Rows.Add(dr)
Dim str As String
Dim Conn1 As SqlConnection = New SqlConnection("workstation Id=SHAILY;packet size=4096;integrated security=SSPI; data source=SHAILY; PERSIST SECURITY INFO=FALSE;INITIAL CATALOG=customer")
'CMD.Connection = Conn
str = "INSERT INTO DETAILS '(CUSTID,NAME,ADDRESS,PHONE,POBOX)'+'VALUES(CUSTID,@NAMEBOX,@TBADDRESS,@TBPHONE,@POBOX)'"
Dim CMD1 As New SqlCommand(str, Conn1)
CMD1.Parameters.Add("TEXT", SqlDbType.Char, 8, "custid")
'par.SourceColumn = "custid"
'par.SourceVersion = DataRowVersion.Original
CMD1.Parameters.Add("TEXT", SqlDbType.VarChar, 50, "name")
CMD1.Parameters.Add("TEXT", SqlDbType.VarChar, 90, "address")
CMD1.Parameters.Add("TEXT", SqlDbType.Char, 10, "phone")
CMD1.Parameters.Add("TEXT", SqlDbType.Char, 10, "pobox")
Conn1.Open()
DA.InsertCommand = CMD1
ElseIf flag = 2 Then
DA.Fill(DS, " tablename ")
dt = DS2.Tables("tablename ")
dr = dt.Rows(0)
custid = TEXTBOX1.Text
dr = dt.Rows.Find(custid)
dr.BeginEdit()
dr(0) = custid
dr(1) = COMBOBOX1.Text
dr(2) =TEXTBOX2.Text
dr(3) = TEXTBOX3.Text
dr(4) = COMBOBOX2.Text
dr.EndEdit()
Dim DA As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM tablename", Conn)
DA.UpdateCommand = New SqlCommand("UPDATE tablename SET Name = @Name " & _
"WHERE CUSTID = @CUSTID", Conn)
DA.UpdateCommand.Parameters.Add("@Name", SqlDbType.NVarChar, 15, "Name")
Dim workParm As SqlParameter = DA.UpdateCommand.Parameters.Add("@CUSTID", SqlDbType.Int)
workParm.SourceColumn = "CUSTID"
workParm.SourceVersion = DataRowVersion.Original
Dim DS As DataSet = New DataSet
DS.Fill(DS, "tablename")
Dim cRow As DataRow = DS.Tables("tablename").Rows(0)
cRow("Name") = "New name"
End If
flag = 0
DA.Update(DS, "tablename")
DA.fill(DS,”tablename”)
MsgBox("data saved---")
End Sub
|
|
|
|
|
Hi All,
I need to show all the menu items in the form into treeview
but i am not able to get the menu name its only giving the
menu text. any methods are available to get the name of the
menuitem object.
reply me yaar!!
V.Gopi.
Easy Design Systems
Coimbatore
India
|
|
|
|
|
Are you sure there's no name property (I don't remember it by heart)?
Anyway, an easy way is give the tag property the same value of the name and recall that one.
|
|
|
|
|
Hi all,
can any one quickly tell me how can i change my button with an image of my choice and also to play a sound on mouse click and mouse over.
replies could be send directly to my email address described below.
Jennifer Wadhani
jenniferaahmed@yahoo.com
|
|
|
|
|
Hello
For changing the button picture you need to drag an imagelist on the form. Add as many images as you like in the imagelist. Now to show any image on the button you need to select the imagelist in button's 'imagelist' property. Now all the images you ve added in the imagelist are visible to your button. Use 'ImageIndex' property of the button to change the images.
_mubashir
|
|
|
|
|
For playing sound...use the following
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Public Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
Public Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy
' Use the following library
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
' call
PlaySound("FilePath And Name", 0, SND_NOSTOP)
_mubashir
|
|
|
|
|
Thanks mubashir, i will try n get bac to u, Thanks a lot dear to show ur concern.
Regards
Jennifer Wadhani
jenniferaahmed@yahoo.com
|
|
|
|
|
I want to write a Listening Music Program with VB.NET but I don't know what place I begin!
|
|
|
|
|
For playing sound...use the following
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Public Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
Public Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy
' Use the following library
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
' call
PlaySound("FilePath And Name", 0, SND_NOSTOP)
V.Gopi.
Easy Design Systems
Coimbatore
India
|
|
|
|
|
Hi guys.. ok, here is my situation. I am doing SQL database programming ith VS 2003. I did a sql database called 'test.adp'. In this DB there is two tables.. ONe is 'Customer', the other is 'Temp'. In both this tables is the field 'Name'.
Okay, let's say the field 'Name' under the table 'Customer' have only one data in text form called 'David' . In the 'Temp' table, there is no data in it.
Is it possible for me to create a button and put a command in it where it will open up the 'customer' table, extract that 'David' data and insert it into the 'Temp' table under the 'Name' Field? Can anyone give me a brief command example that can accomplish this? Thanz for your time..
|
|
|
|
|
OK I'm not trying to be a jerk, just being honest.
No one is going to answer this question because probably no one on this forum has the time or interest in teaching basic SQL and data access in VB.NET. If we did have the inclination, we would not have the time because we'd be busy with either teaching or writing a book.
That's just the basic truth.
Yes this is possible - you can use a SELECT query to get data from one table and an INSERT query to put it in the other. Or use about half a dozen other ways.
All of which require some basic understanding of SQL and data access. You have to learn that on your own.
Again I don't want to seem like a jerk, it's just reality. You can do it - nobody here will do it for you.
We all have to start somewhere, and I understand that the MSDN is not the place - it's just not useful until you reach a certain level.
But the same is true of this forum.
What you need at this point is a good reference book. A beginning book of any kind. If you feel like you are good with picking things up quickly, a beginner book may seem overly simple - in which case certification books often give more technical but useful overviews. To learn NET initially I used the MCSD 70-360 Exam book published by Que, authored by Mike Gunderloy. It is a great quick start. Costs you $50 new, but how much is your time worth?
If you don't have the money, or just want to look at something right now, here is freebie on the web - I don't think it is that great, but it is better than nothing:
http://www.interplat.com/VBNet.pdf[^]
Godd Luck .... seriously
|
|
|
|
|
Been through that book, it doesn't go through SQL database programming. Select and Insert Command.. We are getting somewhere eventually.. Beasically, I am not asking anyone to write the whole code down for me. as Mentioned on the starting thread, I gave a small example of what I am trying to do and hopefully, someone out there who is helpful enough and have some spare time in his hands can help out.. This is what this thread is for, after all..
So anyone else with some knowledge on this and is willing to help... Will appreciate your time...
|
|
|
|
|
hi all
in my project i have table emp.i want to put all my data accessing function add,delete,update in my class.in my form a will use this class object to accessing function.how i can do this.
|
|
|
|
|
use this function for retrival
Public Function FetchData(ByVal tableName As String, Optional ByVal sql As String = "", Optional ByVal Transaction As OleDb.OleDbTransaction = Nothing, Optional ByVal mAddWithKey As Boolean = True) As DataTable
Dim tblData As DataTable
If sql = "" Then
DADPTable = New OleDb.OleDbDataAdapter("Select * from " & tableName, DataConnection)
Else
DADPTable = New OleDb.OleDbDataAdapter(sql, DataConnection)
End If
If Not Transaction Is Nothing Then
DADPTable.SelectCommand.Transaction = Transaction
End If
DADPTable.AcceptChangesDuringFill = True
If mAddWithKey Then DADPTable.MissingSchemaAction = MissingSchemaAction.AddWithKey
tblData = New DataTable(tableName)
DADPTable.Fill(tblData)
FetchData = tblData
tblData = Nothing
End Function
Use this function for update :
Public Sub UpdateData(ByVal tableName As DataTable, Optional ByVal Transaction As OleDb.OleDbTransaction = Nothing)
Dim commandBuild As OleDb.OleDbCommandBuilder
DADPTable = New OleDb.OleDbDataAdapter("Select Top 1 * from " & tableName, DataConnection)
If Not Transaction Is Nothing Then DADPTable.SelectCommand.Transaction = Transaction
Dim tblAdd As DataTable = ds.Tables(tableName).GetChanges(DataRowState.Added)
Dim tblModify As DataTable = ds.Tables(tableName).GetChanges(DataRowState.Modified)
Dim tblDelete As DataTable = ds.Tables(tableName).GetChanges(DataRowState.Deleted)
If Not tblAdd Is Nothing Then
If tblAdd.Rows.Count > 0 Then
commandBuild = New OleDb.OleDbCommandBuilder(DADPTable)
DADPTable.InsertCommand = commandBuild.GetInsertCommand()
If Not Transaction Is Nothing Then DADPTable.InsertCommand.Transaction = Transaction
DADPTable.Update(tblAdd)
End If
End If
If Not tblModify Is Nothing Then
If tblModify.Rows.Count > 0 Then
commandBuild = New OleDb.OleDbCommandBuilder(DADPTable)
DADPTable.UpdateCommand = commandBuild.GetUpdateCommand()
If Not Transaction Is Nothing Then DADPTable.UpdateCommand.Transaction = Transaction
DADPTable.Update(tblModify)
End If
End If
If Not tblDelete Is Nothing Then
If tblDelete.Rows.Count > 0 Then
commandBuild = New OleDb.OleDbCommandBuilder(DADPTable)
DADPTable.DeleteCommand = commandBuild.GetDeleteCommand()
If Not Transaction Is Nothing Then DADPTable.DeleteCommand.Transaction = Transaction
DADPTable.Update(tblDelete)
End If
End If
DADPTable = Nothing
commandBuild = Nothing
End Sub
V.Gopi.
Easy Design Systems
Coimbatore
India
|
|
|
|
|
Hi,
Can someone please brief me on how to save 'pdf' files(there are about 15 files) into a SQL database and retrieve/open it from a datagrid?
I have about 15 pdf files on my webserver and need to save it in the SQL database, so every pdf file saved in the database will have a primary key and the file will be saved either as 'ntext' or 'binary' type...I just have this rough idea.
If someone has a ready code in VB.net then nothing better( i know thats a shortcut but it will help me like a tutorial. C# code will do too, I can then convert the code to Vb.net
Thanks a ton.
Aartee.
...HE is watching Us All!
|
|
|
|
|
Does anyone know how to write help files for a VB program I wrote?
I need to add help files to the program, but I've got no idea how to do this.
Thanks alot
|
|
|
|
|