|
h0k3n9 wrote: Because vb6 has help me to get jobs and get money from it
In that case you better hurry to VB.NET, as VB6 is dead. It's no longer sold, and the modern platforms will not be built with VB6 in mind. Unless you still develop for Windows 95, it's time to move on..
..or become a part of history
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You could download the VB.NET 2012 for free here[^]. Think that would be just as helpful as any other answers youd likely to get.
|
|
|
|
|
|
I've been working around this for years and think it's time I finally learn something.
I need to implement what in MS Access would be a "Form_Current" event. An event that fires each time a new record is displayed from the underlying record set and *after* the controls have their values.
I've tried BindingSource.PositionChanged and BindingSource.CurrentChanged but they're no good because I can't rely on the controls actually having a value. Using the change event on each control (in this case) would be a royal pain because so much goes on when the record changes (things light up, bells and whistles go off, etc.)
What's the best practice?
|
|
|
|
|
I have a vb6 project with a form with a Apex TruedbGrid 6 Oledb datasource that has as an ADODC (Ado 6.0 sp6) on the same form.
cn.ConnectionString = "Provider=SQLNCLI.1;Data Source=pc-musica;Initial Catalog=QdE;User ID=sa;Password=*******"
In Form_Load :
Adodc.ConnectionString = cn.ConnectionString
Adodc.RecordSource = "Select Code, Description from Cantine"
Adodc.Refresh
When executes last statement Adodc.Refresh only on Windows 7 (because everything works quietly in Xp) gives me the error:
Login failed for the user, type: -2147217843 Automation Error.
I checked the connection string and it is also right when the program uses the same connection to open a recordset and operates quietly.
The connection is declared in a module.
How do you think I can fix on Windows 7 32 bit?
|
|
|
|
|
|
This is not my case. I don't change password e don't work with SharePoint
|
|
|
|
|
Well try another Google search for that error code.
Use the best guess
|
|
|
|
|
marco.bruni wrote: How do you think I can fix on Windows 7 32 bit?
By moving to VB.NET; there's no guarantee that anything VB6 will work on the modern platforms. It has been dead quite some time now.
marco.bruni wrote: Login failed for the user, type: -2147217843 Automation Error.
Did you register your TruedbGrid? And all the other stuff referenced?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You could download the VB.NET 2012 for free here[^]. Think that would be just as helpful as any other answers youd likely to get.
|
|
|
|
|
I am getting this error when ever I want to add a second student to a form that has a Student ID that is Auto incremented. I first tried inserting all field to the database using the following code but failed to insert the Student photo and the enroll date properly.
Private Sub SaveBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveBtn.Click
Dim m, fe, F, P, H As String
Dim STPhoto As Image
Dim EnrollDate As Date
EnrollmentDateTxt.Value = Format(Now.Date, "yyyy-MM-dd")
EnrollDate = EnrollmentDateTxt.Value
Dim TA As StudentEnrollmentDataSetTableAdapters.StudentEnrollmentTblTableAdapter
TA.Insert(StudentIDTxt.Text, TelephoneTxt.Text, FirstNameTxt.Text, MiddleNameTxt.Text, LastNameTxt.Text, LevelTxt.Text, ClassroomTxt.Text, GuardianFnTxt.Text, GuardianLnTxt.Text, InstructorLnTxt.Text, m, fe, F, P, H, StudentPhoto.Image, DoBTxt.MaxDate, EnrollDate.Date, GraduationDateTxt.MaxDate, AboutStudentTxt.Text)
So I decided to use the dataset drag & drop feature to see if it can be helpful. It worked for the first entry but if I want to add another student right after the first one I am Getting the Concurrency Violation and the
Me.TableAdapterManager.UpdateAll(Me.StudentsListDataSet) is highlighted.
here is the full save button code:
Private Sub SaveBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveBtn.Click
If FirstNameTextBox.Text.Trim = "" Then
MsgBox("Fadlan Gali magaca hore ee Ardayga", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "First Name box cannot be empty")
FirstNameTextBox.Text = Focus()
Exit Sub
End If
If FirstNameTextBox.Text.Contains(".") Or FirstNameTextBox.Text.Contains("-") Then
MsgBox("Adeer Dhibic iyo xariixin lama ogala ee magaca hore ee ardayga gali", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "First Name box cannot contain (.) or (-)")
Exit Sub
End If
Try
Me.Validate()
Me.FulltimeStudentsTableBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.StudentsListDataSet)
MsgBox("Waxaad ku dartay 1 arday ", MsgBoxStyle.OkOnly, "One Student Added to Students lists")
Me.StudentsListDataSet.Dispose()
Me.TableAdapterManager.Dispose()
Me.Refresh()
I am not sure what
I am doing wrong as I when trough the code line by line and couldn't figure it out. I will highly appreciate if anyone can point me to what I am doing wrong. I even added an Insert Query into the table adapter to handle the table insert. Please help me if you can with any of my methods.
Thank you in advance. ![Sleepy | :zzz:](https://www.codeproject.com/script/Forums/Images/smiley_snore.gif)
|
|
|
|
|
IgaBaro wrote: that has a Student ID that is Auto incremented.
Has it been set as a primary key in the database?
IgaBaro wrote: It worked for the first entry but if I want to add another student right after the first one I am Getting the Concurrency Violation and the
How do the update and insert-statements look like? Can you post them here?
Alternatively, you could try your luck on MSDN; How to: Update Data by Using a TableAdapter[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Quote: Has it been set as a primary key in the database?
Yes its set as PRIMARY KEY as well Unique.
Quote: How do the update and insert-statements look like? Can you post them here?
I have posted this and here it is again.
Private Sub SaveBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveBtn.Click
Dim m, fe, F, P, H As String
Dim STPhoto As Image
Dim EnrollDate As Date
EnrollmentDateTxt.Value = Format(Now.Date, "yyyy-MM-dd")
EnrollDate = EnrollmentDateTxt.Value
Dim TA As StudentEnrollmentDataSetTableAdapters.StudentEnrollmentTblTableAdapter
TA.Insert(StudentIDTxt.Text, TelephoneTxt.Text, FirstNameTxt.Text, MiddleNameTxt.Text, LastNameTxt.Text, LevelTxt.Text, ClassroomTxt.Text, GuardianFnTxt.Text, GuardianLnTxt.Text, InstructorLnTxt.Text, m, fe, F, P, H, StudentPhoto.Image, DoBTxt.MaxDate, EnrollDate.Date, GraduationDateTxt.MaxDate, AboutStudentTxt.Text)
UPDATE: I created another Table with the StudentID not set as a primary key & Unique unchecked and it seems to work while its still Auto incremental set. I think It doesn't like the Auto incremental/primary key & Unique all at the set to true at the same time.
Can anyone tell me why My TA.Insert(StudentPhoto, EnrollDate) doesn't work?? StudentPhoto is set to Image and Enrolldate is using DateTimePicker. what am I doing wrong??
Thank you in advance.
|
|
|
|
|
IgaBaro wrote: I have posted this and here it is again.
My bad; the table-adapter is a class that does some magic in the background. It uses SQL-statements to do it's magic. I'd like to see both SQL statements. Those are the ones used to insert and update, the code you shown calls those in the background.
From MSDN[^];TableAdapters use data commands to read to and write from the database. The TableAdapter's initial Fill (main) query is used as the basis for creating the schema of the associated data table, as well as the InsertCommand, UpdateCommand, and DeleteCommand commands associated with the TableAdapter.Update method. This means that calling a TableAdapter's Update method executes the statements created when the TableAdapter was originally configured, and not one of the additional queries added with the TableAdapter Query Configuration Wizard.
When you use a TableAdapter, it effectively performs the same operations with the commands that you typically would perform. For example, when you call the adapter's Fill method, the adapter executes the data command in its SelectCommand property and uses a data reader (for example, SqlDataReader) to load the result set into the data table. Similarly, when you call the adapter's Update method, it executes the appropriate command (in the UpdateCommand, InsertCommand, and DeleteCommand properties) for each changed record in the data table.
I'd be guessing that the SQL-statement is either incorrect or incomplete, and it might be limited to having a single record.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
hello all .
in this thread, i wanna ask to you how about make steganography in video ?
i wanna use a .NET program.
or if u have articles or all about steganography in video please give to me, because now I'm undergoing my final project at university .
thanks for attention Smile | ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
|
Hi everyone I want some help in my paint application, I am using pictuerbox to draw on it but in the last day my requirement is change that the user want to open an image and do all the functionality on it.. I try to open an image but when I choose some option to draw on the image its didn’t show...
I want some clue quickly please …
Its show for me this exception :
System.ArgumentNullException was unhandled
Message=Value cannot be null.
Parameter name: image
ParamName=image
Source=System.Drawing
StackTrace:
at System.Drawing.Graphics.FromImage(Image image)
at Paint_Note.Form1.OpenToolStripMenuItem_Click(Object sender, EventArgs e) in C:\Users\Lucky\Documents\Visual Studio 2010\Projects\Paint\Paint\Paint_Note.vb:line 340
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Paint_Note.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
|
|
|
|
|
Lolo Hyun wrote: I want some clue quickly please You have failed to initialise some reference before trying to use it, hence the System.ArgumentNullException . Find out what line in your program that occurred on and fix the reference.
Use the best guess
|
|
|
|
|
The line
FromImage(Image image) from the method "OpenToolStripMenuItem_Click" is throwing an error. Go to line 340 of the file "Paint_Note.vb", that's where the error is. Copy/paste the routine on the forum and we can help a bit more.
Lolo Hyun wrote: in the last day my requirement is change Whehe - aight, have someone build a house, and wait until the final day. Now tell them you want the basement on the second floor.
Once there's a deal, there's no change in requirement without changing the deal.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi, this is my first post on these forums. Hope this is in the right place.
Doing a college project where we control an rc car wired into an Arduino over the network from a computer.
It's been brilliant doing this project and all the stuff I've learned from the electronics to the coding, and I've gotten pretty well as far as I thought I could with a lot of help from this forum and many others, so thanks for that.
Decided to do the coding in VB 2008 cos of how quick and easy it was to get things running with VB in first year, but there was no constraint on language choice, and if anyone thinks another language is better suited to this I'd love to hear thoughts on that too. Anyway, having not used VB in a couple of years this forum and a few others were invaluable for rooting out which methods and things I needed to put this together, couldn't have even gotten started without it. But I wanted to postpone posting for as long as possible and get as much done on my own as I could first, which I think I have.
I have a solution pretty much working, and I wanted to get more expert opinions on how it could be improved or implemented better (even if it should be scrapped and a different approach taken, I'm sure it's far from perfect).
Here's the skiinny:
VB app checks for held keys with GetAsyncKeyState, and various combos (of arrow keys) cause particular character to be sent in UDP packet to Arduino, which does it's thing based on the character in the packet. The held keys was chosen as the most intuitive method of controlling an rc car from the pc, and I'm using a timer's tick to run the GetAsyncKeyState, and what I suspect might be a somewhat convoluted system of variable comparisons to prevent a packet from being sent until the state of the held keys changes.
UDP was chosen for speed, though I'm really not sure what difference it would make in the real world if trying to control the rc over the internet say with live keyboard control, and whether it would be viable with UDP and not an alternative, or whether it wouldn't make a practical difference, or whether it wouldn't be viable at all!
Anyway, the thing is working, and sending packets only on initial press or release of key(s). The one glitch I've so far detected is that when releasing all the keys, which should send the "z" character and stop the car, the same character that was previously sent is re-sent, rather than the 'stop' character "z".
So here's the code, VB 2008:
Imports System.Text
Imports System.Net
Imports System.Net.Sockets
Public Class Form1
Dim GLOIP As IPAddress
Dim GLOINTPORT As Integer
Dim bytCommand As Byte() = New Byte() {}
Dim udpClient As New UdpClient
Dim controlChoice As New Integer
Dim controlChoicePrev As New Integer
Dim cc As String = "z"
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer
Dim WithEvents Tmr As New Timer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
controlChoice = 0
controlChoicePrev = controlChoice
Tmr.Interval = 100
Tmr.Start()
End Sub
Private Sub Tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tmr.Tick
Tmr.Stop()
If Not controlChoice = controlChoicePrev Then
Try
GLOIP = IPAddress.Parse("192.168.1.177")
GLOINTPORT = 8888
udpClient.Connect(GLOIP, GLOINTPORT)
bytCommand = Encoding.ASCII.GetBytes(cc)
udpClient.Send(bytCommand, bytCommand.Length)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End If
If GetAsyncKeyState(Keys.Up) Or GetAsyncKeyState(Keys.Down) Then
Select Case True
Case GetAsyncKeyState(Keys.Up)
If (GetAsyncKeyState(Keys.Up)) And (GetAsyncKeyState(Keys.Left)) Then
Label1.Text = "Forwards Left"
controlChoicePrev = controlChoice
controlChoice = 11
cc = "b"
ElseIf (GetAsyncKeyState(Keys.Up)) And (GetAsyncKeyState(Keys.Right)) Then
Label1.Text = "Forwards Right"
controlChoicePrev = controlChoice
controlChoice = 12
cc = "c"
Else
Label1.Text = "Forwards"
controlChoicePrev = controlChoice
controlChoice = 10
cc = "a"
End If
Case GetAsyncKeyState(Keys.Down)
If (GetAsyncKeyState(Keys.Down)) And (GetAsyncKeyState(Keys.Left)) Then
Label1.Text = "Backwards Left"
controlChoicePrev = controlChoice
controlChoice = 21
cc = "e"
ElseIf (GetAsyncKeyState(Keys.Down)) And (GetAsyncKeyState(Keys.Right)) Then
Label1.Text = "Backwards Right"
controlChoicePrev = controlChoice
controlChoice = 22
cc = "f"
Else
Label1.Text = "Backwards"
controlChoicePrev = controlChoice
controlChoice = 20
cc = "d"
End If
End Select
Else
Label1.Text = "Stopped"
controlChoicePrev = controlChoice
controlChoice = 0
End If
Tmr.Start()
End Sub
End Class
So like I said, I'm just wondering if anyone would comment on this and make suggestions/crits.
Many TIA
PS. I'm still pretty code illiterate, so if layman's terms and really explicit and comprehensive and well commented code snippets is not too big an ask... like when people start using terms like call and pass, invoke, etc, I can just about follow things but not always. Sorry...
|
|
|
|
|
![Go to Parent](https://www.codeproject.com/App_Themes/CodeProject/Img/arrow-up24.png) Hey there,
Interesting project you have here Must be a lot of fun to work on. I see this post was from a week back, so likely you have already figured this out for yourself, but for what it's worth I'll reply.
I added a few remarks/comments to your code; I'm not going to nitpick on the finer details, as most of the code looks good! I did notice that you are using the Select Case in an odd way and it's probably best to just make an If-Then-ElseIf statement of it.
Jose Sallamanca wrote: Anyway, the thing is working, and sending packets only on initial press or release of key(s). The one glitch I've so far detected is that when releasing all the keys, which should send the "z" character and stop the car, the same character that was previously sent is re-sent, rather than the 'stop' character "z".
So here's the code, VB 2008:
Private Sub Tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tmr.Tick
Tmr.Stop()
If Not controlChoice = controlChoicePrev Then
Try
GLOIP = IPAddress.Parse("192.168.1.177")
GLOINTPORT = 8888
udpClient.Connect(GLOIP, GLOINTPORT)
bytCommand = Encoding.ASCII.GetBytes(cc)
udpClient.Send(bytCommand, bytCommand.Length)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End If
If GetAsyncKeyState(Keys.Up) Or GetAsyncKeyState(Keys.Down) Then
Select Case True
Case GetAsyncKeyState(Keys.Up)
If (GetAsyncKeyState(Keys.Up)) And (GetAsyncKeyState(Keys.Left)) Then
Label1.Text = "Forwards Left"
controlChoicePrev = controlChoice
controlChoice = 11
cc = "b"
ElseIf (GetAsyncKeyState(Keys.Up)) And (GetAsyncKeyState(Keys.Right)) Then
Label1.Text = "Forwards Right"
controlChoicePrev = controlChoice
controlChoice = 12
cc = "c"
Else
Label1.Text = "Forwards"
controlChoicePrev = controlChoice
controlChoice = 10
cc = "a"
End If
Case GetAsyncKeyState(Keys.Down)
If (GetAsyncKeyState(Keys.Down)) And (GetAsyncKeyState(Keys.Left)) Then
Label1.Text = "Backwards Left"
controlChoicePrev = controlChoice
controlChoice = 21
cc = "e"
ElseIf (GetAsyncKeyState(Keys.Down)) And (GetAsyncKeyState(Keys.Right)) Then
Label1.Text = "Backwards Right"
controlChoicePrev = controlChoice
controlChoice = 22
cc = "f"
Else
Label1.Text = "Backwards"
controlChoicePrev = controlChoice
controlChoice = 20
cc = "d"
End If
End Select
Else
Label1.Text = "Stopped"
controlChoicePrev = controlChoice
controlChoice = 0
End If
Tmr.Start()
End Sub
End Class
My first comment 1) only applies if you are using Win64 and running/coding a 32 bits application (typical). There is a major bug in windows which prevents exceptions being thrown from the Load event to be caught by your program or the debugger - the exceptions are silently thrown away and execution continues with the hope that the exception isn't too serious. If you're interested in reading about it, here's a link to the article I found after many frustrations with this problem: http://blog.paulbetts.org/index.php/2010/07/20/the-case-of-the-disappearing-onload-exception-user-mode-callback-exceptions-in-x64/[^].
For this reason, it might actually be a good idea to place the majority of the code in the Load event in 'Sub New' (the constructor) instead. When you create a new function called Sub New in the IDE, by just typing in the Form code Sub New<enter> Visual Basic will automatically generate the following code for you:
Sub New()
InitializeComponent()
ADD THE LOAD CODE HERE
End Sub
This is the best place to put such code and still have exceptions work (actually, it's always the best place to initialise members).
Secondly, the way BLOCK 1 and BLOCK 2 are positioned is that at the first tick it is detected that a key is pressed but only at the second tick is the change transmitted, so you are manually introducing a 100 ms lag.
If you swap the positions of BLOCK 1 and BLOCK 2 then the code first checks the key states and then immediately transmits.
Finally, UDP is not a reliable protocol by design, so it might be a good idea to send the controlChoice even if it is equal to the controlChoicePrev every couple of ticks (like, every half second/5 ticks) to mitigate the results of package loss, which can occur with UDP.
Hope this helps you, if only a bit. Good luck.
Best Regards,
Richard
|
|
|
|
|
Hello,
I made a .batch script which is unmount usb disk F: or eject.
The command is very simple, "mountvol F: \D" and it's dissconnected or ejected.
What i was wodering is, how do i do in vb.net ?
|
|
|
|
|
You can use the Process Class[^] to run external commands.
Use the best guess
|
|
|
|
|
|
We got a customer who uses a Access DBs with code inside - one DB with Forms and Modules, the second stores the data. Two users work together from their computers on those DBs stored in the network.
Well, the devloper they had went into retirement. So I had the pleasure to port the Access 97/2000 DBs to 2003/2010. No there are some funny errors appearing just in their network not in our. I went to them cause I wasn't able to replicate those errors. Now it's even stranger. I tried to debug them, but they didn't appeared. I stopped debugging and the errors were thrown - not all the time but most times.
Access messages that a record is locked by another user although I was the only one today working on the db. There are error-messages, that an update wasn't successful but the data is stored correctly, after leaving the form all data is correct when I open it again.
It seems, that there is a timing / synchronisation error. I think the programm-code is faster than the operations in the data-db. But as debugging isn't possible it's hard to find the source.
Is there a way for a better synchronisation?
One user has Windows XP, the other one Windows 7 both use Access 2003 SP 3.
Regards,
Ingo
------------------------------
Author of Primary ROleplaying SysTem
How do I take my coffee? Black as midnight on a moonless night.
War doesn't determine who's right. War determines who's left.
|
|
|
|
|