Picker issue in codenameone - codenameone

I have two pickers. The 2nd picker should be active as soon as the 1st picker is selected. But If the 2nd picker is clicked at first, the empty picker string is opened and then dialog stating choose the 1st picker is shown. How can I not show the empty picker string list if the first picker is not selected ?
Picker datePicker = new Picker();
datePicker.addActionListener(e -> {
SimpleDateFormat sf = new SimpleDateFormat("y");
String a = sf.format(datePicker.getDate());
SimpleDateFormat sf1 = new SimpleDateFormat("M");
String b = sf1.format(datePicker.getDate());
SimpleDateFormat sf2 = new SimpleDateFormat("d");
String c = sf2.format(datePicker.getDate());
getStartDate = a + "-" + b + "-" + c;
});
stationPicker.addActionListener(e -> {
if (!getStartDate.equals("")) {
_ _ _ _ _ _ _ _ _ ___ _
_ _ _ _ _ _ _ _ _ ___ _
}else{
Dialog.show("Warning", "Please choose the date first", "ok", null);
stationPicker.setSelectedString("Select the service center");
}
});
Have a look at the video so that the issue is more clear.
https://www.youtube.com/watch?v=Fmg13qm08Is

Related

Putting a new item in to the calendar overwrites the other item inside

Hello can someone please tell me what could be the problem in my calendar. So let me explain whats happening. So first im trying to make a scheduler application and im using a WPF scheduler in VB, so to begin with, the tab of a calendar needs to display 3 items (Subject, Professor Name, Courses) so what i need to do is to choose a room first and then drag a subject name from the listbox (like this Sample1) and then next i need to drag a professors name (Sample2) and then heres where the problems starts
So it already displays two items (Subject and Professor) now i need to drag an item from Course listbox, but the problem is whenever I put a course to the tab of a calendar, it becomes like this instead
So the goal here is to show 3 dragged items but instead, it only shows 2 and the course is overwriting the name of the subject. Please help me, thank you! If you want to see the whole codes, heres the link https://drive.google.com/file/d/1fWKisPr9qDh54B4EMdwWJbY3KFgi_xfc/view?usp=sharing
Heres the code of where you can drag the items
'Dragging Data to Calendar
Sub Add_list_item(ByVal list As String)
Delay.Delay(1)
Dim count = 0
For Each item As CalendarItem In Calendar1.GetSelectedItems()
count += 1
If count > 1 Then
Return
Else
Dim get_item_end_time As DateTime = item.EndDate.AddHours(2)
get_item_end_time = get_item_end_time.AddMinutes(30)
Dim item_start_time = item.StartDate
Dim item_end_time = get_item_end_time
Dim item_tooltip = item.StartDate.ToString()
Dim start_time = item.StartDate.ToString("HH:mm tt")
Dim end_time = item.EndDate.ToString("HH:mm tt")
Dim dat_start As Date = item_tooltip
Dim ci As CultureInfo = CultureInfo.CreateSpecificCulture("en-US")
Dim dtfi As DateTimeFormatInfo = ci.DateTimeFormat
dtfi.AbbreviatedDayNames = {"Sun", "1", "2", "3", "4",
"5", "6"}
Dim output_start As String = String.Format(ci, "{0:ddd}", dat_start.AddDays(0))
Dim item_text = CStr(item.Text)
Dim parts As String() = item_text.Split(New String() {Environment.NewLine},
StringSplitOptions.None)
Dim get_item_total_hours = (item.EndDate - item.StartDate).TotalHours
Dim get_start_time As DateTime
Dim get_end_time As DateTime
If get_item_total_hours = 1 Then
get_start_time = item.StartDate.AddMinutes(-30)
get_end_time = item.EndDate.AddMinutes(30)
ElseIf get_item_total_hours = 1.5 Then
get_start_time = item.StartDate.AddHours(-1)
get_end_time = item.EndDate.AddHours(1)
ElseIf get_item_total_hours = 2 Then
get_start_time = item.StartDate.AddHours(-1).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(1).AddMinutes(30)
ElseIf get_item_total_hours = 2.5 Then
get_start_time = item.StartDate.AddHours(-2)
get_end_time = item.EndDate.AddHours(2)
ElseIf get_item_total_hours = 3 Then
get_start_time = item.StartDate.AddHours(-2).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(2).AddMinutes(30)
ElseIf get_item_total_hours = 3.5 Then
get_start_time = item.StartDate.AddHours(-3)
get_end_time = item.EndDate.AddHours(3)
ElseIf get_item_total_hours = 4 Then
get_start_time = item.StartDate.AddHours(-3).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(3).AddMinutes(30)
ElseIf get_item_total_hours = 4.5 Then
get_start_time = item.StartDate.AddHours(-4)
get_end_time = item.EndDate.AddHours(4)
ElseIf get_item_total_hours = 5 Then
get_start_time = item.StartDate.AddHours(-4).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(4).AddMinutes(30)
ElseIf get_item_total_hours = 5.5 Then
get_start_time = item.StartDate.AddHours(-5)
get_end_time = item.EndDate.AddHours(5)
ElseIf get_item_total_hours = 6 Then
get_start_time = item.StartDate.AddHours(-5).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(5).AddMinutes(30)
End If
If (ListBox1_Instructor.Items.Contains(list) = True) Then
Call Check_if_instructor(list)
End If
If parts.Count >= 3 Then
If (instructor_name = True) Then
Call Get_instructor_code(instructor_gender + list)
Call Get_course_name(corSec_id)
Call checkInstructorSchedule(start_time, end_time, output_start, instructor_id)
If (instructor_name = True) Then
If instructor_gender = "Male" Then
instructor_gender = "Mr. "
Else
instructor_gender = "Ms. "
End If
If item.Text <> "" Then
item.Text = parts(0) + vbNewLine + vbNewLine + instructor_gender + list
item.ApplyColor(Color.RoyalBlue)
End If
instructor_name = False
End If
Else
item.ApplyColor(Color.RoyalBlue)
item.Text = list + vbNewLine + vbNewLine + parts(2) + vbNewLine + vbNewLine
End If
ElseIf parts.Count = 1 Then
If (instructor_name = True) Then
Call Get_instructor_code(instructor_gender + list)
Call Get_course_name(corSec_id)
Call checkInstructorSchedule(start_time, end_time, output_start, instructor_id)
If (instructor_name = True) Then
If instructor_gender = "Male" Then
instructor_gender = "Mr. "
Else
instructor_gender = "Ms. "
End If
If item.Text <> "" Then
item.Text = parts(0) + vbNewLine + vbNewLine + instructor_gender + list
item.ApplyColor(Color.RoyalBlue)
End If
instructor_name = False
End If
Else
item.ApplyColor(Color.RoyalBlue)
item.Text = list + vbNewLine + vbNewLine + parts(parts.Count - 1) + vbNewLine + vbNewLine
End If
End If
Calendar1.Invalidate(item)
End If
Next
End Sub

How to set content into mui-rte with selenium webdriver in python?

I am using mui-rte rich text editor (https://github.com/niuware/mui-rte) in a react project. I am not able to figure out how to input text to the rte input area when writing a selenium webdriver integration test.
As I understand correctly, mui-rte is a materia-ui wrapper of draftjs. The react code is simply:
<MUIRichTextEditor
onChange={onChange}
value={initial}
{...rest}
/ >
This generates the following html elements:
<div id="mui-rte-container" class="MUIRichTextEditor-container-73">
<div id="mui-rte-toolbar" class="MUIRichTextEditor-toolbar-84">
...
</div>
<div id="mui-rte-editor" class="MUIRichTextEditor-editor-75">
<div id="mui-rte-editor-container" class="MUIRichTextEditor-hidePlaceholder-79 MUIRichTextEditor-editorContainer-76">
<div class="DraftEditor-root">
<div class="DraftEditor-editorContainer">
<div aria-describedby="placeholder-9mnek" class="notranslate public-DraftEditor-content" role="textbox" spellcheck="false" style="outline:none;user-select:text;-webkit-user-select:text;white-space:pre-wrap;word-wrap:break-word" contenteditable="true">
<div data-contents="true"><div class="" data-block="true" data-editor="7kjuh" data-offset-key="8a2rc-0-0">
<div data-offset-key="8a2rc-0-0" class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr">
<span data-offset-key="8a2rc-0-0">
<br data-text="true">
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I can easily find any of the element but when I try this for example:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
from selenium.webdriver.common.by import By
rte_editor = WebDriverWait(self.driver, 2).until(
EC.presence_of_element_located((By.ID, id))
)
rte_input = bio_rte.find_element_by_xpath("//div[#role='textbox']")
rte_input.send_keys("Hello")
I get:
E selenium.common.exceptions.ElementNotInteractableException: Message: Element <div class="notranslate public-DraftEditor-content"> is not reachable by keyboard
With all elements that I have tried.
What is the correct way to input text into draft.js rte with selenium-webdriver in python? I am quite new to selenium+webdriver and any help will be appreciated, be it in python, JavaScript or other flavor of selenium-webdriver API.
I have a sample project here: https://github.com/vessper/formik-mui-rte-example
update:
Including the stack trace from the error:
self = <test.TestBase testMethod=test_input_text_in_rte>
def test_input_text_in_rte(self):
rte_input = WebDriverWait(self.driver, 20).until(
EC.element_to_be_clickable(
> (By.XPATH, '//div[#class="notranslate public-DraftEditor-content" and #role="textbox"]'))
)
test.py:25:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <selenium.webdriver.support.wait.WebDriverWait (session="38c21bf5-27ea-499d-9831-e8755a10f57a")>
method = <selenium.webdriver.support.expected_conditions.element_to_be_clickable object at 0x7f7115fe7198>, message = ''
def until(self, method, message=''):
"""Calls the method provided with the driver as an argument until the \
return value is not False."""
screen = None
stacktrace = None
end_time = time.time() + self._timeout
while True:
try:
value = method(self._driver)
if value:
return value
except self._ignored_exceptions as exc:
screen = getattr(exc, 'screen', None)
stacktrace = getattr(exc, 'stacktrace', None)
time.sleep(self._poll)
if time.time() > end_time:
break
> raise TimeoutException(message, screen, stacktrace)
E selenium.common.exceptions.TimeoutException: Message:
../../../.virtualenvs/ml2/lib/python3.7/site-packages/selenium/webdriver/support/wait.py:80: TimeoutException
================================================================= 1 failed in 24.70s ==================================================================
In my case it was a draft.js rich text editor with a contenteditable div
async sendKeysToContentEditableDiv(element, text) {
const script = `var txtarea = arguments[0],txt = arguments[1];
txtarea.dispatchEvent(new Event("focus"));
var txtEvt = document.createEvent("TextEvent");
txtEvt.initTextEvent("textInput", true, true, null, txt);
txtarea.dispatchEvent(txtEvt);
txtarea.dispatchEvent(new Event("blur"));`;
await this.driver.executeScript(script, element, text);
}
The desired element is a ReactJS enabled element so to locate and send a character sequence to the element you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following solutions:
Using CSS_SELECTOR:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.notranslate.public-DraftEditor-content[role='textbox']"))).send_keys("Vess_Perfanov")
Using XPATH:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[#class='notranslate public-DraftEditor-content' and #role='textbox']"))).send_keys("Vess_Perfanov")
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Update
As the click() is still not invoked with WebDriverWait you can use ActionChains as follows:
Using CSS_SELECTOR:
element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.notranslate.public-DraftEditor-content[role='textbox']"))).send_keys("Vess_Perfanov")
ActionChains(driver).move_to_element(element).click(element).send_keys("Vess_Perfanov").perform()
Using XPATH:
element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[#class='notranslate public-DraftEditor-content' and #role='textbox']"))).send_keys("Vess_Perfanov")
ActionChains(driver).move_to_element(element).click(element).send_keys_to_element(element, "Vess_Perfanov").perform()
There is an inline label element from Material-UI that needs to be clicked first to uncover the underlying text field. So the following work for me.
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
import unittest
class TestBase(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.get(URL)
def tearDown(self):
self.driver.close()
def get_by_id(self, id):
return WebDriverWait(self.driver, 5).until(
EC.presence_of_element_located((By.ID, id))
)
def test_input_text_in_rte(self):
description_msg = "Hello There"
rte_container = self.get_by_id('mui-rte-container')
rte_label = rte_container.find_element_by_xpath("//*[contains(text(), 'Description:')]")
actions = ActionChains(self.driver)
actions.move_to_element(rte_label)
actions.click(rte_label)
actions.perform()
rte_input = WebDriverWait(self.driver, 5).until(
EC.presence_of_element_located((By.XPATH,
'//div[#class="notranslate public-DraftEditor-content" and #role="textbox"]'))
)
rte_input.send_keys(description_msg)
Thanks to #DebanjanB for the suggestions that are incorporated in the code above.

Show the particular component of the screen when backed

I've a screen with a list of components. When I scroll down the screen, go to the next screen from a button (lets say 20th component) and go back to the previous screen with back btn, the previous screen (with list of components) displays with the first component there. How can I show the screen with 20th component when backed?
Look at the video here
Container mainContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
mainContainer.setScrollableY(true);
for (Map<String, Object> entrySet : protectedPlantsList) {
String title = entrySet.get("title").toString();
String sname = entrySet.get("sname").toString();
String nname = entrySet.get("nname").toString();
Label plantSpeciesLabel = new Label(title);
TextArea family = new TextArea(sname);
TextArea nepaliName = new TextArea(nname);
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Button infoIcon1 = new Button("", "TextField");
infoIcon1.addActionListener(e -> {
new ThreatCategory(res, threatData1.getName(), infoIcon1.getName(), threatList).show();
});
mainContainer.add(BorderLayout.centerEastWest(plantSpeciesLabel, ...., .....));
}
Update 1:
ProtectedPlantAndSpecies class:
Container mainContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
mainContainer.setScrollableY(true);
for (Map<String, Object> entrySet : protectedPlantsList) {
String title = entrySet.get("title").toString();
String sname = entrySet.get("sname").toString();
String nname = entrySet.get("nname").toString();
Label plantSpeciesLabel = new Label(title);
TextArea family = new TextArea(sname);
TextArea nepaliName = new TextArea(nname);
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Button infoIcon1 = new Button("", "TextField");
infoIcon1.addActionListener(e -> {
Form myDestinationForm = new ThreatCategory(res, cat, cat_description, threatList);
myDestinationForm.addShowListener(f -> infoIcon1.requestFocus());
myDestinationForm.show();
});
mainContainer.add(BorderLayout.centerEastWest(plantSpeciesLabel, ...., .....));
}
ThreatCategory class:
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
Command backCommand = new Command("Back", backFontImage) {
#Override
public void actionPerformed(ActionEvent evt) {
new ProtectedPlantAndSpecies(res, true).show();
}
};
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
Do something like this:
Form hi = new Form("Last", BoxLayout.y());
Button t = new Button("Next");
hi.add(t);
t.addActionListener(e -> {
Form f = new Form("Showing Last", BoxLayout.y());
for(int iter = 0 ; iter < 20 ; iter++) {
f.add(new Button("Button " + iter));
}
Button last = new Button("Last");
f.add(last);
f.addShowListener(ee -> last.requestFocus());
f.show();
});

Microsoft VBScript runtime error '800a01a8'

I have website which is working on my one server now I have migrated to another server changed the connection string. But one weird thing is some pages working fine but some page show me " page can not be displayed error message. I am new in VBscript Can anyone help me what am missing"
Below is the code of page which is not working on new server but working on old server
Microsoft VBScript runtime error '800a01a8' : object required
<%#LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% if session("MM_Username") = "" or isnull(session("MM_Username")) then
response.redirect("/login.asp")
end if
%>
<%
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then
MM_editConnection = MM_v3_STRING
MM_editTable = "dbo.custMessage"
MM_editColumn = "id"
MM_recordId = "" + Request.Form("MM_recordId") + ""
MM_editRedirectUrl = "Change.asp"
MM_fieldsStr = "textarea|value"
MM_columnsStr = "message|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
Dim change__MMColParam
change__MMColParam = "1"
If (Request("MM_EmptyValue") <> "") Then
change__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Dim change
Dim change_numRows
Set change = Server.CreateObject("ADODB.Recordset")
change.ActiveConnection = MM_v3_STRING
change.Source = "SELECT * FROM dbo.custMessage WHERE id = " + Replace(change__MMColParam, "'", "''") + ""
change.CursorType = 0
change.CursorLocation = 2
change.LockType = 1
change.Open()
change_numRows = 0
%>
<%
'setup database connection
dim conn
set conn = server.CreateObject ("ADODB.Connection")
conn.ConnectionString = "Provider=SQLOLEDB;User ID=***;Password=***;Initial Catalog=heart_Test;Data Source=****;"
conn.Open
%>
So here is the answer.
Start Internet Services Manager.
Click Default Web Site, and then click Properties.
Double-click ASP in the Features pane.
Expand Behavior.
Click Enable Parent Paths.
Click True for Enable Parent Paths.
Click Apply.

Updating the table and displaying the current data

I am trying to update the table which is working but after updating I cannnot see the updated data on the form when I ho to next record and comeback eventhough it gets updated on sql server.
Here is my code
Try
cn = Connection.connectionstringESLC()
cn.Open()
Dim query As String
query = "Update [School Admin Aug 2012] SET NAME='" & txtName.Text & _
"' , ADDRESS = '" & txtAddress.Text & _
"' , [Alternate Email] = '" & txtEmail.Text & _
"' , [ADVISOR NAME] = '" & txtAdvName.Text & _
"' , [DEPT NAME] = '" & txtDept.Text & _
"' , PROGRAM = '" & txtDegree.Text & _
"' , DEGREE = '" & txtMajor.Text & _
"', MAJOR = '" & txtProgram.Text & _
"', [DATE ADMITTED] = '" & dtpAdmitted.Value & _
"', [ADMISSION DECISION] = '" & cmbAdmDecision.Text & _
"' , [ENROLLMENT STATUS] = '" & cmbEnrollment.Text & _
"', [CAMPUS] = '" & cmbCampus.Text & _
"' , [ADVISING SHEET DATE] = '" & dtpAdvshtdt.Value & _
"' , [GRADUATION DATE] = '" & dtpGrdDt.Value & _
"' , [CURRENT POSITION] = '" & txtCurrentPosition.Text & _
"' , [GRE] = '" & txtGRE.Text & _
"' , [SLLA] = '" & txtSLLA.Text & _
"' , [KYPT] = '" & txtKYPT.Text & _
"' , [COMMENT] = '" & txtComment.Text & _
"' WHERE [MNUMBER] = '" & txtMNumber.Text & "'"
cmd = New SqlCommand(query, cn)
cmd.ExecuteNonQuery()
cn.Close()
cn = Nothing
MsgBox("Record updated successfully")
loadinfo()
Catch ex As Exception
MsgBox(ex.Message)
End Try
' I am also running loadinfo() code on page_load function
Public Sub loadinfo()
Try
cn = Connection.connectionstringESLC()
cn.Open()
cmd = New SqlCommand("Select * from [School Admin Aug 2012]")
cmd.Connection = cn
da.SelectCommand = cmd
da.Fill(ds, "dbo.School Admin Aug 2012")
da.Dispose()
cmd.Dispose()
If i < ds.Tables(0).Rows.Count - 1 Then
txtMNumber.Text = ds.Tables(0).Rows(i).Item(0)
txtName.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(1)), " ", ds.Tables(0).Rows(i).Item(1))
' IIf(IsDBNull(ds.Tables(0).Rows(0).Item(2)), " ", ds.Tables(0).Rows(0).Item(2))
txtAddress.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(2)), " ", ds.Tables(0).Rows(i).Item(2))
txtEmail.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(3)), " ", ds.Tables(0).Rows(i).Item(3))
txtAdvName.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(4)), " ", ds.Tables(0).Rows(i).Item(4))
txtDept.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(5)), " ", ds.Tables(0).Rows(i).Item(5))
txtProgram.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(6)), " ", ds.Tables(0).Rows(i).Item("PROGRAM"))
txtDegree.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(7)), " ", ds.Tables(0).Rows(i).Item("DEGREE"))
txtMajor.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(8)), " ", ds.Tables(0).Rows(i).Item("MAJOR"))
dtpAdmitted.Value = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(9)), "12/31/9998", ds.Tables(0).Rows(i).Item(9))
cmbAdmDecision.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(10)), " ", ds.Tables(0).Rows(i).Item(10))
cmbEnrollment.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(11)), " ", ds.Tables(0).Rows(i).Item(11))
cmbCampus.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(12)), " ", ds.Tables(0).Rows(i).Item(12))
dtpAdvshtdt.Value = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(13)), "12/31/9998", ds.Tables(0).Rows(i).Item(13))
dtpGrdDt.Value = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(14)), "12/31/9998", ds.Tables(0).Rows(i).Item(14))
txtCurrentPosition.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(15)), " ", ds.Tables(0).Rows(i).Item(15))
txtGRE.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(16)), " ", ds.Tables(0).Rows(i).Item(16))
txtSLLA.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(17)), " ", ds.Tables(0).Rows(i).Item(17))
txtKYPT.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(18)), " ", ds.Tables(0).Rows(i).Item(18))
txtComment.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(19)), " ", ds.Tables(0).Rows(i).Item(19))
cn.Close()
cn = Nothing
ElseIf i < 0 Then
i = 0
Else
MsgBox("This is the last record")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Resources