473,395 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

VB.NET web form to SQL database

Subject: VB.NET - forms to data - SQL


Hi,

Stuck on a project here. ASP.NET / VB / SQL. Trying to get a VB.NET check box to write a True or False value into a SQL database. Having a bear of a time with this.

See my sample data / database schema here:

http://sql-paul.com/press/default.aspx

I was trying to build some programming with Psuedo Code snips from the net... does this logic make sense?
***********
***********
Expand|Select|Wrap|Line Numbers
  1. if chkDayShift is selected
  2.         write to sql table the value 1 (true) 
  3.     where column name = current checkbox's label
  4. else
  5.     write to sql table the value 0 (false) 
  6.     where column name = current checkbox's label
  7.  
  8. ***********
  9.  
  10. if chkDayShift is selected
  11.         write to ref2 value 1 
  12.     where dayshift = chkDayShift
  13. else
  14.     write to ref2 value 0
  15.     where dayshift = chkDayShift
  16.  
  17. ***********
I saw this snippet from the net... is this something that should be in the command button code?
*******************************
Code to check a CheckBox's state
********************************

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_
  2. System.EventArgs) Handles Button1.Click
  3. If CheckBox1.Checked = True Then
  4. TextBox1.Text = "Checked"
  5. Else
  6. TextBox1.Text = "UnChecked"
  7. End If
  8. End Sub  
*******************************

Any help would be great... source samples if you can please.
Best,
Paul
May 6 '09 #1
4 2967
tlhintoq
3,525 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. if chkDayShift is selected
I'm a C# guy, not VB but...

In C# we would be looking at the Checked property, not the Selected property.

Expand|Select|Wrap|Line Numbers
  1. if (chkDayShift.Checked) 
  2. {
  3. // blah
  4. // blah
  5. }
May 6 '09 #2
Thanks tlhintoq...

Question 1: Any chance you could copy/paste the entire C# block if you have it handy? :-) C# could still be a useful snip, I could paste into the VB project and let the compiler flag the syntax errors!! At least I'd have a leg up on the project.

Question 2: about your if (chkDayShift.Checked) block.... does the source code get written in the submit button coding itself after the
"Private Sub Button1_Click"???

Sorry if I sound so green, the only VB/C#/SQL I've got are my corny tutorials at http://sql-paul.com. Learning more everyday!!

Thanks buddy,
Later
Paul
May 6 '09 #3
tlhintoq
3,525 Expert 2GB
Question 1: Any chance you could copy/paste the entire C# block if you have it handy? :-)
I'm not trying to be evasive, I promise. But copy *what* C# block? I don't have a time scheduling program already written. I was just showing you how a checkbox in C# compares the .Checked property as compared to how you were doing "is selected".
Question 2: about your if (chkDayShift.Checked) block.... does the source code get written in the submit button coding itself after the
"Private Sub Button1_Click"???
You could do it that way, though I very rarely write any method directly into the button click handler. It becomes difficult to call later when you need to re-use that same function. Instead I write a method to do what I need it to do, then have the button.click handler call that method.

Expand|Select|Wrap|Line Numbers
  1. private void MyCoolButton_click(object sender, eventargs e)
  2. {
  3.      DoCoolFunction();
  4. }
  5.  
  6. private void DoCoolFunction()
  7. {
  8.    // Here is 100 lines of cool code that actually performs a task
  9. }
  10.  
  11. private void DoTotalProcess()
  12. {
  13.      DoMathFunction();
  14.      DoCoolFunction(); // Now I can reuse Cool function more easily
  15.      DoGraphFunction();
  16. }
  17.  
The concept here is to write small descrete methods that have only one purpose in life. They are black boxes that know little or nothing of the world around them. They take in parameters, they return parameters. Then if you need an entire process performed, you call 20 of the descrete functions in the right order. This is much better than writting one giant function that performs 20 steps. What would happen if you had to remove one step, or add one step? In the example above you could comment one method call, or insert a method call, and keep the overall process clean and human readable.
May 6 '09 #4
Hi tlhintoq - thats really helpful... thanks... I'll move my efforts in that direction.

important points I gathered from you:
> thlintoq - checked as opposed to 'is selected'
--- I saw some other code leaning that direction

> thlintoq - avoid writing methods into button click handlers
--- I see your point on this, easier to modify later, etc

> thlintoq - calls to functions
--- I've seen small examples of this, calls are better for reuse especially
during program changes

Thanks buddy,
big help
later
paul
May 6 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: djharrison | last post by:
I'm new to ASP and database programming but I am trying to connect to a database using a concatenation of a strings and a menu item from a form. Ok here's what I have... an asp form that has a...
1
by: Neil Mansell | last post by:
hi all, i just wondered if i could pikc any of your brains out there and ask whats the wasiest way to make a quiz-type program using ms-access. so i can create or import questions and it has a...
2
by: Big E | last post by:
I'm using ASP.Net and SQL Server. I have a table called states. I have 2 forms. On form 1 is the 50 states in textboxes created with a loop. I want to have those 50 or 45 or whatever amount of...
13
by: Schoo | last post by:
I have a VB.NET program called "Calendar" that has a menu on the top that opens up another form (like a pop-up box) on top of "Calendar". The pop-up box form is called "Memos" which is a...
4
by: paul1664 | last post by:
Hi, I'm currently loading my masterpage from a file via an httpmodule. How can I modify this code to load the masterpage from a database? Is the only way to save the file to a temp file first...
2
by: Robert | last post by:
I have a form with a print button on it which opens a report. I specify the id in the where clause in the OpenReport statemt say the report prints for the current record. This works fine for...
1
by: katta.naveenkumar | last post by:
Hi friends My name is naveen kumar katta .My task is insert database values to pdf template with editable mode plz help me frieds.using ASP.NET I am giveing ex: step 1:
2
by: wassimdaccache | last post by:
Hy to all I'm using access 2003 (11.5614.5606) I have a database called "form" that I imported all my forms on it and I linked tables of "forms " into another database called "tables" what...
1
by: PL19 | last post by:
hi, my requirement is i have to import data to quick books from my sql database can anybody please help me thanks in advance
1
by: pspwzrd | last post by:
Hi i am a admin in the clan |Gp| (www.clan-gp.com).i am also the web-designer.i am looking for anyone who could help me build a php code that has a from etc that new members to the clan can fill in,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.