LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add and delete user in table

Solved!
Go to solution

Hi, guys. I am doing a system which is allowed admin to control user.

The ID is = admin

The pass is = 6649481

Can anyone help me to check for the add and delete part.

Actually, it can work but I would like to make it not repeat is allowed but this only work on the index "0" then from index 1 it will not stop user to add repeated ID.

Delete part if I were removing the loop will be fine and work fine but it can only delete from the top. It's like First in first out concept but I wish to make it like according by the ID given to delete from table.

Download All
0 Kudos
Message 1 of 13
(3,321 Views)

Hi KinniHan,

 

From your code, I noticed that there are quite a lot of flaws in both Add User and Delete User event, mostly on the array functions. I'll just break it down one by one.

Let's start with the Add User:

1) I believe this portion of the code below is to determine the array size of the Add New User control (I don't see why you do not use indicator instead), but you did not wire any input value (0, 1 or 2, since there are only 3 columns) in the disabled index (col).

Capture.PNG

So what will happen in that the index (row) will automatically be assigned to default value 0 (In other words, it will extract only the data from row 0 of Add New User table) and the array size of the first row of Add New User is 3.

 

(Will add more later)



See that button on the left side of this post...

If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~



Message 2 of 13
(3,300 Views)

Sorry for making confsing and thanks for concern.
Initially I was setting it as 0 and I just changing for getting more idea. But I was failed at last and decided to remove the connection first. 

0 Kudos
Message 3 of 13
(3,289 Views)

Alright, what you can do is just wire value 0, 1 or 2 in the in the disabled index (col) of the Index Array, and you should be able to obtain the number of rows (in turn, the number of the usernames in the table), which you can use it for the While Loop. Same goes to similar codes in the Delete User event.

 

Move on the next one in Add User event.

2) In this portion of the code below,

Capture.PNG

a) I would assume that you want the While Loop to stop if the (iteration number + 1)* is equal to the number of users registered on the table. But here, you have placed Less or Equal? function, which results in the While Loop to only run 1 iteration.

 

In other words, this portion of the code is comparing the UserName with only the user name on the 1st column of the table, instead of all the columns. Replace this with Equal? function, and place Increment function before the Equal? function.

* - Note that the iteration number starts from 0 at 1st iteration.

 

(For some reason, you manage to wire the input terminals of the Less or Equal? function (almost) correctly in Delete User event, but not in Add User event)

 

b) I also assume that you want to stop the loop if UserName is empty OR UserName is equal to one of user name in the table. Use Or functions, together with output terminal of the Equal? function, so that you can immediately stop the loop if:

- UserName is empty, OR

- UserName is equal to one of the username in the table (repeated name), OR

- (Iteration number + 1)* is equal to the number of username on the table

 

I think with that, you should be able to make it work.

Actually, there are better alternatives that you can do to improve your code, but as of now, I can help you to fix up your code.

Also, I suggest you to understand what your code is doing and ensure that you're wiring the data correctly to input/output terminals of the functions. Try play around with the functions and see what each function does.

 

Ee Lim



See that button on the left side of this post...

If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~



Message 4 of 13
(3,280 Views)

Thank for your help and finally I made it works!

Yea, I did play around with the function and that's why I didn't link the numeric to the array as you shown me before. I have forgotten to connect it back acutally.

Why you said my delete function is almost correct? Now I can only delete the first one. Still finding the error of my code 😞

0 Kudos
Message 5 of 13
(3,239 Views)

May I ask how to do 3 action by single button? Because in my application I would like to using the button "course" to light up 3 different LED and 1 by 1. 
For example:
Click once = LED 1 = T, LED 2 = F, LED 3 = F
Click twice = LED 1 =F, LED 2 = T, LED  3 =F
Click third = LED 1 =F, LED 2 = F, LED 3 = T
Click fourth = LED 1 = T, LED 2 = F, LED 3 = F

and so on.......
I have tried to using while loop but I have failed at last. I think someting wrong with my logical.

0 Kudos
Message 6 of 13
(3,220 Views)

Hi KinniHan,

 

Perhaps you can try combine your 3 LEDs into one array and use the Rotate function from Numerics > Data Manipulation palette.

http://zone.ni.com/reference/en-XX/help/371361K-01/glang/rotate/

 

Regarding the statement about the Delete User event that is almost correct, there's nothing wrong with the code. But it's just a good practice to place the Increment function before the Less or Equal? function (wired from iteration terminal), because as mentioned before, iteration number starts from 0 at the 1st iteration.

 

From your code, let's say if the size of the array is 5, your code will still run at the 6th iteration (the value of i needs to be equal to the size of the array, which is 5) before stopping the While Loop, and the Index Array function is trying to obtain the data from the 6th element which is uninitialized, which will eventually returns a default value of 0.

 

Hope this helps.

 

Ee Lim



See that button on the left side of this post...

If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~



Message 7 of 13
(3,199 Views)
Oh my god, thank you so much for helping me. On the delete part, which mean the way to delete is already correct? I just need focus on my loop part? Because currently I can only delete the first row data and I don't know why. Actually for delete we should search for the string or array index? Could be something wrong on this to caused me unable to delete the other record except the first row?
0 Kudos
Message 8 of 13
(3,191 Views)

Hi KinniHan,

 

Could you attach the modify code so that I can see what else went wrong?

 

Ee Lim



See that button on the left side of this post...

If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~



Message 9 of 13
(3,181 Views)

123.png

 

This is my delete code . Thanks for help 🙂

0 Kudos
Message 10 of 13
(3,158 Views)