473,385 Members | 1,673 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,385 software developers and data experts.

check if user-id exists then edit

Greetings,
im a beginner in vb.net and im trying to make a survey program(which consists of radiobuttons- poor,fair,good,verygood,excellent) that when a user inputs its user-id. the program will check the database whether the user-id has been entered before or not. if existing, the user may edit the original/existing survey record. im using MS SQL as a back-end. and also, i was asked to use 1 form only.

i was just wondering if you guys can help me out by showing some examples of your way of programming it, 'cause honestly, i dont have that much idea yet when it comes to vb.net.

Thank you in advance.
May 23 '12 #1

✓ answered by Pegasus40218

Are you writing an ASP.Net application with VB.Net on the back-end or are you writing a VB.Net Windows Forms application?

4 3494
Are you writing an ASP.Net application with VB.Net on the back-end or are you writing a VB.Net Windows Forms application?
May 24 '12 #2
im writing asp.net with vb.net sir. sorry, i got lost with my message. but the good news is, i finally manage to check user-id if it exists sir. i used read.item. but there's just another one problem. i cant call the sub saverec() which allows the user to save unentered value.

here's my code sir :
Expand|Select|Wrap|Line Numbers
  1. Protected Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  2.  
  3.         Dim con As New SqlConnection
  4.         Dim cmd As New SqlCommand()
  5.         con.ConnectionString = "Data Source = MARITES; Initial Catalog = dbClientFeedBack; Persist Security Info = True; User ID = sa; Password = sa;"
  6.         con.Open()
  7.         cmd.Connection = con
  8.  
  9.         Dim sql As String
  10.         sql = ("SELECT * FROM tblFeedBackPK WHERE ORNum ='" & txtORNum.Text & "'")
  11.         cmd.CommandText = sql
  12.         Dim read As SqlDataReader = cmd.ExecuteReader
  13.         While read.Read
  14.  
  15.  
  16.  
  17.             If read.Item("ORNum").ToString = txtORNum.Text Then
  18.                 Dim msgedit As DialogResult = MsgBox("OR NUMBER ALREADY EXIST, Do you want to edit?", MsgBoxStyle.YesNo)
  19.                 If msgedit = Windows.Forms.DialogResult.Yes Then
  20.                     calling()
  21.  
  22.                 Else
  23.                     txtORNum.Text = ""
  24.                     Page.Form.DefaultFocus = txtORNum.ClientID()
  25.                     button1.Visible = False
  26.                     Button2.Visible = True
  27.                 End If
  28.  
  29.             ElseIf read.HasRows = 0 Then
  30.                 saverec()
  31.             End If
  32.  
  33.         End While
  34.         con.Close()
  35.  
  36.  
  37.  
  38.     End Sub
  39.  
  40.  
here is my saving() sub

Expand|Select|Wrap|Line Numbers
  1. Public Sub saverec()
  2.         Dim con As New SqlConnection
  3.         Dim cmd As New SqlCommand()
  4.         con.ConnectionString = "Data Source = MARITES; Initial Catalog = dbClientFeedBack; Persist Security Info = True; User ID = sa; Password = sa;"
  5.         cmd.Connection = con
  6.         con.Open()
  7.         cmd.CommandText = "INSERT INTO tblFeedBackPK(ORNum,poorAvail,poorPrice,poorTransc,poorStore,poorCourt,poorAccess,fairAvail,fairPrice,fairTransc,fairStore,fairCourt,fairAccess,goodAvail,goodPrice,goodTransc,goodStore,goodCourt,goodAccess,vgAvail,vgPrice,vgTransc,vgStore,vgCourt,vgAccess,excellentAvail,excellentPrice,excellentTransc,excellentStore,excellentCourt,excellentAccess) VALUES('" & txtORNum.Text & "','" & poor1.Checked & "','" & poor2.Checked & "','" & poor3.Checked & "','" & poor4.Checked & "','" & poor5.Checked & "','" & poor6.Checked & "','" & fair1.Checked & "','" & fair2.Checked & "','" & fair3.Checked & "','" & fair4.Checked & "','" & fair5.Checked & "','" & fair6.Checked & "','" & good1.Checked & "','" & good2.Checked & "','" & good3.Checked & "','" & good4.Checked & "','" & good5.Checked & "','" & good6.Checked & "','" & verygood1.Checked & "','" & verygood2.Checked & "','" & verygood3.Checked & "','" & verygood4.Checked & "','" & verygood5.Checked & "','" & verygood6.Checked & "','" & excellent1.Checked & "','" & excellent2.Checked & "','" & excellent3.Checked & "','" & excellent4.Checked & "','" & excellent5.Checked & "','" & excellent6.Checked & "')"
  8.         cmd.ExecuteNonQuery()
  9.         MsgBox("SUCCESS")
  10.         button1.Visible = True
  11.         Button2.Visible = False
  12.  
  13.         clearing()
  14.  
  15.     End Sub
May 25 '12 #3
every time i click the button save (which is not an existing number), nothing happens and and the button just disappears. but when an existing value was entered. the msg prompts asking the user if he wants to edit. after edit was done, still the button just disappears upon saving and nothing happens.

sorry for bothering you pegasus.
any help will be appreciated :)
May 25 '12 #4
@Pegasus40218
WOOHOO! nvm pegs i finally managed to execute it. i removed sub saving() inside the while loop. sorry for bothering you. thank you too :) keepsafe.
God bless :)
May 25 '12 #5

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

Similar topics

0
by: Mike L | last post by:
Configuration Manger will pop up a “Check Out For Edit” box when I change the configuration from “Release” to “Debug”. When I try to check out the solution, error message pops up,...
10
by: Raymond | last post by:
Hi All: To find a file exists using the file name, I have tow routings on UNIX system. 1. access(2) 2. lstat(2) This tow function also can do. When the return value is "-1" and errno is...
1
by: Pete | last post by:
Hi, i'm building a datagrid that grabs a documents location out of a database and puts them in as a hyper link column. Ideally i'd love to be able to check the validity of the link and only...
1
by: James | last post by:
vb.net 2003 i wrote a windows service that does threading. My codes are a) the service thread will read a list of machine from a text file (machines.txt). b) it then logon using the below...
0
by: Herb | last post by:
is there a way in an SQL stored proc to determine if a temp table exists before selecting from it....I have a java app. that is calling a stored proc. i want to check if Java created the table before...
0
by: ramith | last post by:
Guys, I wrote a simple code to check the existence of a directory (in UNIX based file systems) which is working for me. Have I done it in the correct way? #include <dirent.h>
9
reginaldmerritt
by: reginaldmerritt | last post by:
I have a table which uses two primary keys. One is a canidate code the other is a course\programme code. I have a fom with these two fields but automaticaly picks the candidates code. Therefore...
4
by: Mark Berry | last post by:
Hi, I'm working on my "last resort" error block for a web application. If the error occurs after a Request has been made, I want to show the URL. If the Request object is not available, I'll...
0
by: philip.poole | last post by:
Hi everyone, I am settings up some .NET controls on my website and want to create template controls to completely separate the business layer and the presentation layer. However I have...
2
Manikgisl
by: Manikgisl | last post by:
HI. How to check File exists in Web Share C# try { WebRequest request = HttpWebRequest.Create("http://www.microsoft.com/NonExistantFile.aspx"); request.Method = "HEAD"; // Just get...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.