
DannyT
Avatar/Signature-
Posts
36 -
Joined
-
Last visited
DannyT's Achievements
Newbie (1/14)
0
Reputation
-
I've been searching around and experimenting various things for days now for this but am just a bit too green to USB/HID to get my head around it. What I would ideally like to do is write a windows service in c# that will accept input from a USB HID device (specifically a barcode scanner). I want that service to dominate the input from a specific device I.e. the input will not be output to the currently focused application as if it were typed on a keyboard. Is this possible? I've managed to bodge-hijack input with a winforms app using windows events but that just trapped certain key combinations and stole focus and then returned focus on other key combinations. This didn't really work as it wasn't fast enough and some input was lost to the currently focused app or was disrupted if a user was typing whilst scanning. I want to detect a specific HID and then directly consume that HIDs input. Can anyone suggest how I might do this without resorting to writing device drivers? Is this even possible? Thanks for any help, very much appreciated. Dan
-
I'm creating an application that recieves input from a USB barcode scanner. By default the input from the scanner is exactly as if the input were from a usb keyboard, I.e. if I leave notepad open, scan a barcode that barcode sequence get's "typed" into notepad. What I want to do is detect when input is received from the barcode scanner and take that input and use it in my own application rather than wherever the cursor happens to be at the time. Has anyone any suggestions on how I could achieve this? Any help much apprecaited. Dan
-
Insert to db from new strongly typed datarow
DannyT replied to DannyT's topic in Database / XML / Reporting
Thanks plausibly, I am doing that, the above is just a generic function that I can throw any dataset at once updates have been made. I'm currently evaluating strongly typed datasets vs custom classes. -
Insert to db from new strongly typed datarow
DannyT replied to DannyT's topic in Database / XML / Reporting
ah thank you tfowler! I had explored that before but dismissed it, after your post I went back and realised where i was going wrong. For the benefit of others, here is how to update a dataset with a new dataadapter: Public Function ExecuteUpdateDS(ByVal ds as DataSet, ByVal sql as String) as Integer Dim da As New OleDbDataAdapter 'create new dbAdapter da.SelectCommand = New OleDbCommand(sql, myConnection) ' same select command that was used in the initial dataset population Dim autogen As New OleDbCommandBuilder(da) ' CommandBuilder, auto generates Update, Insert and Delete commands Dim rowsUpdated as Integer= da.Update(ds, "Customers") ' commit update ds.AcceptChanges() ' accept modifications to dataset ExecuteUpdateDS = rowsUpdated End Function -
Insert to db from new strongly typed datarow
DannyT replied to DannyT's topic in Database / XML / Reporting
Okay this got the better of me so I resorted to filling the dataset, I then needed to maintain a reference to that dataset which I have done, now I'm sending the dataset to a commitToDb function I realise I need a reference to the original dataadapter I filled it from?! Is this correct? How do I update a dataset to the database using a new dataadapter? I'm sorely missing a trick somewhere as using strongly datasets seems to be very tightly coupling my users' interaction with the data itself. -
I have a strongly typed dataset, called "Customers" for example. My user chooses to create new customer, i have no existing dataset, so i create a new instance of my Customers dataset. dim dsCustomers as new Customers and instantiate a new CustomersDataRow. dim drCustomer as new dsCustomers.Tables(0).NewRow() At this point i've not Filled my ds as I know i'm creating a new record and don't want to make an unneccessary call to the db. I populate my NewRow with the required data. How do I now insert this row into the actual database? I'm trying to pass it to my attempt at a data access layer (which currently has no reference to the original dataset). I seem to be stuck with a detached datarow and can't figure out how to commit it to the database? I'm sure this shouldn't be as difficult as i'm making it but i seem to be having a slow day so any help much appreciated. Regards, Dan
-
databinding multiple list controls to the same datasource
DannyT replied to DannyT's topic in Windows Forms
Thanks plausibly, i've just been looking at this. However, all i can find is examples of how to keep the same selections on bound controls. E.g. clicking a next button will increment a "current item" textfield and also the selected item in a combo. My form seems to already be doing this but I don't want it to, if you can come up with any samples that'd be great. I'll post back if I find anything too. Cheers, Dan -
On my form I have a combobox and 2 checklistboxes, I'm trying to populate them all from the same datasource (an arraylist). The populating is fine, however once populated, if I select something in the combobox, the same items get selected in the other two lists?! I didn't think an arraylist has a "selected" property or collection so why is it doing this? I want to bind to the same datasource but allow each of the lists to have their own different selections???
-
aha! Thanks plausibly, I'd bodged it by manually bubbling the event, but I think addhandler will be a cleaner approach. I'm working on a .net implementation of the ARP Flash Platform framework. So far its going well... Thanks again!
-
I have an MDI form i'm using as an Application class This application "has a" login form as a private property which is exposed to a consuming application controller class via a public getter. I want my controller to handle a login event raised by the login form, however I cannot seem to handle events of the login form as a property of the application? E.g. (pseudo code) Public Class Application private controller as Controller private login as LoginForm Public ReadOnly Property UserLoginForm() As LoginForm Get Return Me.login End Get End Property Private Sub Application_Load() Handles MyBase.Load Me.controller = controller.GetInstance Me.controller.RegisterApp(Me) RaiseEvent AppLaunched() End Sub End Class Public Class Controller Private Property withevents viewRef as Application Public Sub new(app as Application) me.viewRef = app End Sub Public Sub GetInstance() As Controller 'singleton code End Sub '**********THE PROBLEM CODE*********** Public Sub UserLogin() Handles viewRef.UserLoginForm.loginEvent 'can't access UserLoginForm's events??? 'do something with a command End Sub End Class The problem is my UserLogin function on the controller can't seem to access the Applications UserLoginForm property to handle it's events. Hope that makes some sort of sense and someone can help?
-
I have a windows app that i'm developing in vb.net running on an oracle9i db. I have some procedures that return data based on values input by the user, I now need to display the results of these procedures in graphs, I have never done anything like this so anyone that can point me in the right direction is much appreciated. I have attached a spreadsheet showing the exact graphs i'd like to recreate and some dummy source data. Cheers, Dan Graph_mock_ups.zip
-
I hope someone can shed some light on this it's driving me potty: I have a vb.net app running on an oracle 9i back end. The issue is with populating one datatable, on my dev machine, connecting to same db it works fine (even when running installed, deployed package), on another machine it completely ignores a field as follows: Table: CREATE TABLE tbl_order_status ( order_status_id NUMBER(10) NOT NULL, order_status NVARCHAR2(2) DEFAULT '00', order_status_name VARCHAR2(20), CONSTRAINT pk_order_status PRIMARY KEY(order_status) ); data: -- NB there is a trigger which inserts an autonumber type primary key into the first field INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('00', 'status00'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('0', 'status0'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('01', 'status01'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('02', 'status02'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('03', 'status03'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('04', 'status04'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('05', 'status05'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('5W', 'status5W'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('06', 'status06'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('07', 'status07'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('08', 'status08'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('09', 'status09'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('10', 'status10'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('11', 'status11'); INSERT INTO tbl_order_status(order_status, order_status_name) VALUES('99', 'status99'); stored procedure: CREATE OR REPLACE PACKAGE pkg_order_status AS TYPE rc_order_status IS REF CURSOR; END; / show errors CREATE OR REPLACE PROCEDURE sp_select_order_status (c_order_status OUT pkg_order_status.rc_order_status) IS BEGIN OPEN c_order_status FOR SELECT DISTINCT order_status_id, order_status, order_status_name FROM tbl_order_status; END; / When i run the procedure from SQL Plus (on either machine) I get the results as expected: SQL> VAR c1 REFCURSOR SQL> execute sp_select_order_status(:c1); PL/SQL procedure successfully completed. SQL> print c1 ORDER_STATUS_ID OR ORDER_STATUS_NAME --------------- -- -------------------- 1 00 Status00 2 0 Status0 3 01 Status01 4 02 Status02 5 03 Status03 6 04 Status04 7 05 Status05 8 5W Status5W 9 06 Status06 10 07 Status07 11 08 Status08 ORDER_STATUS_ID OR ORDER_STATUS_NAME --------------- -- -------------------- 12 09 Status09 13 10 Status10 14 11 Status11 15 99 Status99 15 rows selected. The problem is when i populate a dataset table with the results from that procedure it populates fine on my dev machine, but on the live machine the 2nd field (order_status) is always blank. ' get order statuses to dataset With dbadpt ' set command object properties With cmdOrderStatus .Connection = getCn() .CommandText = "sp_select_order_status" .CommandType = CommandType.StoredProcedure .Parameters.Add("c_order_status", OracleType.Cursor).Direction = ParameterDirection.Output End With ' select command .SelectCommand = cmdOrderStatus .TableMappings.Add("Table", "orderStatus") ' fill dataset .Fill(ds) .Dispose() End With ... Dim dr1 As DataRow For Each dr1 In ds.Tables("orderStatus").Select TextBox1.Text = TextBox1.Text & ", " & dr1(1) Next 'dev outputs: "00, 0, 01, 02, 03 .. etc" 'live outputs: ",,,,,,,, etc" This is obviously a pain in the arse to debug as it works fine on my machine! If anyone can offer any guidance or even a better way to debug and narrow down the problem, i'd be extremely grateful. If you need any more info please dont hesitate to ask. Cheers, Dan
-
Ahhh cheers plausibly, the descriptions in the Post Formatting section are a bit screwy for csharp. Ta!
-
I read other posts and they all contain wonderfully stylized c# samples. mine always displays massively spaced out and no colours: - [csharp] public class uglyFormatting { public void uglyFormatting { throw new Exception("UGLY"); } } [/csharp] i use [charp] and [/csharp ] tags is that wrong?
-
This is actually a method of a factory class implemented because i wanted to perform a common function with the type created by the factory which i was previously doing in the factory. E.g. //(before) public class MemberCollectionFactory { public ArrayList CreateCollection(DataEntity member, string type) { myCollection.Clear(); switch (type) { case "myString1": foreach (DataRow row in dt.Rows) { myEntity = new MyType1; myEntity.Create(row); // MyType1 overrides the Create(row) with implmentation ABC myCollection.Add(myEntity); } break; case "someType2": foreach (DataRow row in dt.Rows) { myEntity = new MyType2; myEntity.Create(row); // MyType2 overrides the Create(row) with implmentation XYZ myCollection.Add(myEntity); } break; //...etc } return myCollection; } } //(after) public class MyFactory { public ArrayList CreateCollection(DataEntity member, string type) { myCollection.Clear(); switch (type) { case "someType1": createList(new MyType1()); break; case "someType2": createList(new MyType2()); break; //etc } return myCollection; } public ArrayList createList(DataEntity mytype) { foreach (DataRow row in dt.Rows) { myEntity = (DataEntity)Activator.CreateInstance(mytype.GetType()); myEntity.Create(row); myCollection.Add(myEntity); } return myCollection; } } just refactoring, I'm sure there's a better way but this works, any suggestions on improvements gratefully recieved. Dan p.s. why does my c# code in here get so spaced out, does the same if I copy, paste or type directly in?