|
I got an error and i have tried so many ways to solve it..but still got error..
my table have 3 columns.. SID(autonumber), movieid(text),seat(text)..
i want to store splitword(1) into movie ID and for the rest splitword(i) where i = 3 , 4 ,5 6 and so on..... store in seat columns with new row..
sorry for bad english..
this is my code:
Dim index As Integer = 2
Dim testsplit As String = "Book 9 j18 d7 d8 a9"
Dim SplitWord() As String = testsplit.Split(" ")
Dim wc As Integer = SplitWord.Length - 1
Do While index <= wc
SeatNewRow.Item("MovieID") = SplitWord(1)
SeatNewRow.Item("Seat") = SplitWord(index)
SeatDS.Tables("Seat").Rows.Add(SeatNewRow)
index += 1
Loop
SeatDA.Update(SeatDS, "Seat")
modified 9-May-12 13:20pm.
|
|
|
|
|
Your code isn't adding new rows, you're modifying existing rows. Well, at least the code you posted. We can't see the code where you create this new row. Where is SeatNewRow being created??
|
|
|
|
|
actually this is only some part of the code..
I have table name Seat..in the table have 3 columns named SID, MovieID and Seat.
Actually i want to save the the word to the tables..
Splitword(1) to the MovieID column..
Splitword(2),splitword(3) and so on in the column "seat" with same value Splitword(1) on movieID.
The code as below..but i got "This row is already belongs to this table"..so, what should i do??
Dim SeatNewRow As DataRow
Dim index As Integer = 2
Dim testsplit As String = "Book 9 j18 d7 d8 a9"
Dim SplitWord() As String = testsplit.Split(" ")
SeatNewRow = SeatDS.Tables("Seat").NewRow()
Dim wc As Integer = SplitWord.Length - 1
Do While index <= wc
SeatNewRow.Item("MovieID") = SplitWord(1)
SeatNewRow.Item("Seat") = SplitWord(index)
SeatDS.Tables("Seat").Rows.Add(SeatNewRow)
index += 1
Loop
SeatDA.Update(SeatDS, "Seat")
..
|
|
|
|
|
You have to put the call to .NewRow() INSIDE the Do While loop, not outside of it. You have to create a new row object for every row you add. You cannot reuse the same object for the reason the error message gave you. You already added it!
|
|
|
|
|
So it is i need modified my code as below???i will try it now..
Dim SeatNewRow As DataRow
Dim index As Integer = 2
Dim testsplit As String = "Book 9 j18 d7 d8 a9"
Dim SplitWord() As String = testsplit.Split(" ")
Dim wc As Integer = SplitWord.Length - 1
Do While index <= wc
SeatNewRow.Item("MovieID") = SplitWord(1)
SeatNewRow.Item("Seat") = SplitWord(index)
SeatNewRow = SeatDS.Tables("Seat").NewRow()
SeatDS.Tables("Seat").Rows.Add(SeatNewRow)
index += 1
Loop
SeatDA.Update(SeatDS, "Seat")
|
|
|
|
|
problem solved....thanx so much...!!!
the solved code is as below:
Dim SeatNewRow As DataRow
Dim index As Integer = 2
Dim testsplit As String = "Book 9 j18 d7 d8 a9"
Dim SplitWord() As String = testsplit.Split(" ")
Dim wc As Integer = SplitWord.Length - 1
Do While index <= wc
SeatNewRow = SeatDS.Tables("Seat").NewRow()
SeatNewRow.Item("MovieID") = SplitWord(1)
SeatNewRow.Item("Seat") = SplitWord(index)
SeatDS.Tables("Seat").Rows.Add(SeatNewRow)
index += 1
Loop
SeatDA.Update(SeatDS, "Seat")
|
|
|
|
|
I use this code to add a custom control to a panel :
Dim usc As New InvoiceCTRL
usc.Top = y
usc.Left = 20
Me.Panel1.Controls.Add(usc)
y = y + 20
when the panel is filled & scroll bar appears,
the added controls appear very distant from each other.
i figured out thats because y is measured from THE Appearing Area of the panel not from the virtual top
is there a solution so the added controls appear uniformly separated from each other ??
all right,
i used a flowlayoutpanel instead,it worked,
modified 9-May-12 4:45am.
|
|
|
|
|
Location is an offset from 0,0 in the client area of the form, not the visible area of the client area of the form. The scroll bars have nothing to do with the placement of controls so there's something else going on that we can't see in your code.
|
|
|
|
|
How can I obtain the sender object from a control handle in VB.net?
I have a function GetProperties(sender)
sender is an Object Type like the one in Form1_Click sited below:
Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
Form2.GetProperties(sender)
Form2.Show()
End Sub
Private Declare Function apiGetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As Int32
I currently can get a handle of a window or of a control that I clicked on as follows:
hwnd = apiGetForegroundWindow ()
How can I obtain the sender object from hwnd so that I can passed into GetProperties as follows: GetProperties(sender)?
Thanks,
|
|
|
|
|
handler huh? how about this[^]
|
|
|
|
|
Thank you so much replying and help. However, this is not exactly what I am looking for. I was trying to find a way to obtain the system of the item that I got the handle for.
For example, public sub button1_click (sender as Object, e As Args)
end sub
For example, public sub button2_click (sender as Object, e As Args)
end sub
For example, if the user click on button or any control, after I obtain the handle of the control being clicked I want to be able to trace back or obtain the sender of the handle.
hwnd = getHandle(button1)
I am trying to find a way to obtain the sender of hwnd so that I can pass the sender into a function whose parameter requires sender object, for example,
SenderObject = getSender(hwnd) 'How do I get the Senderobject from a control or a window hwnd so
that I can pass it into a function or sub that means to accept sender object as follows?
Call Button2_Click(SenderObject, e)
Thanks,
|
|
|
|
|
Only controls have handles. Cast your sender-object to a control, and you can access the property.
What is it that you're trying to achieve?
Bastard Programmer from Hell
|
|
|
|
|
Thank you very much for your info and help.
I have am trying to obtain all the properties of any window, control, or object that the user will click on.
I am currently, have function that accepts a sender and displays all the sender's properties.
For example, if the user clicked on button1,
in
Sub Button1_click(sender As Object, e As args)
GetProperties(sender) ' Right now I can do
' this fine.
End Sub
I can also do GetProperties(Me.ActiveControl) fine too.
However, when the user clicks on a window or a button of another application, I can obtain the handle of this window or this button as buttonhandle or windowhandle; however, I cannot pass windowhandle or buttonhandle directly into GetProperties as
GetProperties(windowhandle or buttonhandle) this does not work because GetProperties requires sender argument to be passed into it as follow GetProperties(getSender(windowhandle) or getSender(buttonhandle))
How do I get SenderObject = getSender (windowhandle) from windowhandle or
SenderObject = getSender (windowhandle) from windowhandle
so that I can pass it into GetProperties(SenderObject)?
Thanks,
|
|
|
|
|
Member 3746076 wrote: How do I get SenderObject = getSender (windowhandle) from windowhandle so that I can pass it into GetProperties(SenderObject)?
You can't. The other app might be using a custom treeview that your app doesn't know anything about.
No, won't work if you're looking at another process. What you're trying to achieve can be found here[^], with sourcecode.
Bastard Programmer from Hell
|
|
|
|
|
Thank you so much replying and help. However, this is not exactly what I am looking for. I was trying to find a way to obtain the sender object of the item that I got the handle for.
I am trying to obtain all the properties of any obeject that the user clicks on.
Currently, I can alread obtain the handle of the oject or of the control being clicked on, but I do not how to trace the handle back to its sender type or object.
For example, public sub button1_click (sender as Object, e As Args)
end sub
For example, public sub button2_click (sender as Object, e As Args)
end sub
For example, if the user click on button or any control, after I obtain the handle of the control being clicked I want to be able to trace back or obtain the sender of the handle.
hwnd = getHandle(button1)
I am trying to find a way to obtain the sender of hwnd so that I can pass the sender into a function whose parameter requires sender object, for example,
SenderObject = getSender(hwnd) 'How do I get the Senderobject from a control or a window hwnd so
that I can pass it into a function or sub that means to accept sender object as follows?
Call Button2_Click(SenderObject, e)
Thanks,
|
|
|
|
|
how can i code a datagridview with 3 columns:
textbox-textbox-combobox
textbox1 has an autocomplete collection;
when i select or type a string of it a matching number appear in textbox2;
and editing textbox2 affects the combobox's selected index ??
also how to make pressing enter moves to the first cell in the new row ??
|
|
|
|
|
The best solution for this would be to research using Google. However two URL's you may wish to review are....
http://www.dotnetperls.com/datagridview-vbnet
http://vb.net-informations.com/datagridview/vb.net_datagridview_tutorial.htm
|
|
|
|
|
Thanks,
I found a really helpful tutorial here :
http://www.codeproject.com/Articles/26289/Editable-and-Multi-Functional-Datagridview
|
|
|
|
|
I have a combobox attached to a database with names in it. How do I get the combolist to show only the name of the text typed as it is type. IE: If I type "A" I want the list to display only the names that start with the letter "A". I was able to do this in the VB6 but lost the function when I upgraded to Visual
Studio 2010.
Please help!!!!
cjscs
|
|
|
|
|
Not to hard to add the functionality.
Have a start here[^].
|
|
|
|
|
The AutoComplete functionality Jorgen links you to is nice. But you might be asking for a simple way to filter your list items (which could be used in conjunction with AutoComplete). Have a look at the BindingSource class and its Filter property. Something like this:
Dim bs As New BindingSource
bs.DataSource = dtTable
Me.ComboBox1.DataSource = bs
Me.ComboBox1.DisplayMember = "DISPLAY_COLUMN"
Private Sub ComboBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
bs.Filter = "DISPLAY_COLUMN LIKE '" & e.KeyChar & "%'"
End Sub
|
|
|
|
|
description:
Custom screensaver in vb.net 2008 of a slideshow using local resource images embedded. I got the exe working fine.
general steps done so far:
1) form properties to no border and full screen
2) import images to local resources so they are embedded in the application
3) create a timer to change the form.background to the next image
4) generate a random number reflecting the number of images and confirm no repeats
5) close application trigger (spacebar)
6) test on my systems and work fine as exe
Problem:
#1
Within install shield reg settings pushed
-1 HKCU/controlpanel/dekstop/ScreenSaveActive = 1
-2 ScreenSaveTimeOut = 900 (15 minutes)
-3 SCRNSAVE.EXE = C:\Windows\MICHAE~1.SCR
1 and 3 work
2 doesn't set the screensaver timer to 15 minutes, it stays at the same timer previously entered
#2
right clicking on the desktop of Win 7 and selecting Personalize. The screensaver is there, but clicking on Screen Saver to open up the screensaver properties, the screensaver initiates. Stopping the screensaver brings the screensaver properties up fine. Using another way like Control Panel > Appearance and Personalization > Change screen saver works as expected. Using the start>run "screensaver" to open screensaver properties starts the screensaver and after closing the screensaver, the screensaver properties is available.
#3
in the screensaver properties, selecting either settings or preview start the screensaver twice. In other words, the screensaver will start, then after you close it, it starts again a second time.
#4
although the screensaver shows it is in the screensaver properties window. even after waiting the designated time to pass, the screensaver doesn't initiate.
Can someone lend a hand on how to resolve these issues?
www.MichaelHulak.com
modified 7-May-12 1:36am.
|
|
|
|
|
Have you followed the steps outlined here[^]?
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
 i tried, but not successful. Maybe if i show the code i currently have to assist
Imports System.Timers
Imports System.Drawing
Public Class Form1
Dim A As Int16 = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PrevInstance()
' If PrevInstance() = True Then
' MessageBox.Show("sdfsdf")
' Close()
' End
' Else
' MessageBox.Show("222222")
' End If
running()
Dim startPoint1 As New Point(Me.Width / 2 - 165, 19)
lbl_top.Location = startPoint1
Dim startPoint2 As New Point(Me.Width / 2 - 62, 93)
lbl_bottom.Location = startPoint2
A = RandomNumber(0)
Images()
Timer1.Enabled = True
Timer2.Enabled = True
End Sub
Function PrevInstance() As Boolean
If UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then
MessageBox.Show("222222")
Me.Close()
Return True
Else
Return False
End If
End Function
Private Sub Form_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, _
ByVal X As Single, ByVal Y As Single)
Static count As Integer
If count > 2 Then
Me.Close()
End
Else
count = count + 1
End If
End Sub
Public Sub running()
'The end result of this code is similar to Visual Basic 6.0's App.Previnstance feature.
Dim appName As String = Process.GetCurrentProcess.ProcessName
Dim sameProcessTotal As Integer = Process.GetProcessesByName(appName).Length
If sameProcessTotal > 1 Then
MessageBox.Show("A previous instance of this application is already open!", " App.PreInstance Detected!", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Close()
End If
appName = Nothing
sameProcessTotal = Nothing
End Sub
Private Sub CreatePointsAndSizes(ByVal e As PaintEventArgs)
' Create the starting point.
Dim startPoint As New Point(Me.Width / 2 - 331)
' Use the addition operator to get the end point.
Dim endPoint As Point = Point.op_Addition(startPoint, _
New Size(140, 150))
' Draw a line between the points.
e.Graphics.DrawLine(SystemPens.Highlight, startPoint, endPoint)
' Convert the starting point to a size and compare it to the
' subtractButton size.
Dim buttonSize As Size = Point.op_Explicit(startPoint)
End Sub
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, _
ByVal keyData As Keys) As Boolean
' spacebar to escape screensaver
Const WM_KEYDOWN As Integer = &H100
Const WM_SYSKEYDOWN As Integer = &H104
If ((msg.Msg = WM_KEYDOWN) Or (msg.Msg = WM_SYSKEYDOWN)) Then
Select Case (keyData)
Case Keys.Space
Close()
End Select
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
Images()
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer2.Tick
lbl_bottom.Visible = False
lbl_top.Visible = False
Timer2.Enabled = False
End Sub
Public Sub Images()
If A = 1 Then
Me.BackgroundImage = Screensaver_01.My.Resources.Resources._2011_06_07_IMG_2969_WM
A = RandomNumber(1)
Exit Sub
End If
If A = 2 Then
Me.BackgroundImage = Screensaver_01.My.Resources.Resources._2011_06_28_IMG_4278_WM
A = RandomNumber(2)
Exit Sub
End If
If A = 3 Then
Me.BackgroundImage = Screensaver_01.My.Resources.Resources._2011_08_03_IMG_9462_WM
A = RandomNumber(3)
Exit Sub
End If
If A = 4 Then
Me.BackgroundImage = Screensaver_01.My.Resources.Resources._2011_08_21_Confidence_WM
A = RandomNumber(4)
Exit Sub
End If
End Sub
Public Function RandomNumber(ByVal previous_number As Integer, _
Optional ByVal MinNumber As Integer = 1) As Integer
Dim randomObject As Random = New Random()
Dim rndNum As Integer = previous_number
Dim output As String = ""
While previous_number = rndNum
rndNum = randomObject.Next(1, 4)
End While
Return rndNum
End Function
End Class
|
|
|
|
|
how to play videos from my database on my vb.net form.? plz if any one know rly me nw.... 
|
|
|
|