error in retrieving contact from cursor - sms

Cursor cursor = managedQuery(Phone.CONTENT_URI,new String[] { Phone.DISPLAY_NAME, Phone.NUMBER }, Phone.NUMBER + "= ?", new String[]{address},Phone.DISPLAY_NAME+" ASC");
cursor.moveToFirst();
String name=cursor.getString(cursor.getColumnIndex(Phone.DISPLAY_NAME));
the line with the code 'cursor.getColumnIndex(Phone.DISPLAY)' is giving me an error on the phone but not on the emulator.. Can you please tell me can this this happen?? Infact I have used this line in 3 different places.. It works at 2 places and not in 1 place

try this links
http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/

Related

What is the number after the second colon on a Google Apps Script error?

I have a Google Apps Script linked to a Sheet that takes Form responses. I'm getting this error:
I've figured out that 104 is the line number where the error occurs. What does 14 represent? Both numbers are the same every time the error occurs. For context's sake, here's some of the code:
if (Renaming) {
Debug("Renaming Began")
var Section = Values[4]
var Name = Values[5].replace(/\//g, "-").concat(" ", Values[3], "-", Values[2].substring(0, 1)) // Date, space, last name, hyphen, first initial
Debug("Renaming Files...")
DriveApp.getFileById(Documents[0]).setName(Section.concat(" Session Plan ", Name)) // Session plan naming (this is line 104)
Debug("Session Plan Renamed")
DriveApp.getFileById(Documents[1]).setName(Section.concat(" Sign-in ", Name))
Debug("Sign-in Sheet Renamed")
if (Documents.length > 2) {
Debug("Worksheets Detected")
Debug(Documents.length)
for (i = 2; Documents.length; i++) {
if (i > 13) {break}
Debug(("Began ").concat(i))
if (!Documents[i]) {continue}
Debug(("Exists ").concat(i))
DriveApp.getFileById(Documents[i]).setName(Section.concat(" Worksheet #", i - 1, " ", Name))
Debug(("Renamed ").concat(i))
}
Debug("Worksheets Renamed")
}
Debug("Renaming Completed")
} else {
Debug("Renaming Disabled")
}
Explanation:
From this expression: 104:14:
104: represents the row where the error occured.
14: represents the column where the error occured.
Column is defined as the position of each character in the document on the horizontal axis. Each symbol/space/letter/number occupies one column of space.
Example:
the error here is in the 2nd row and there are 2 spaces (columns) before the word error.
But the error starts at the letter e of the word error. So you have 2 spaces (columns) before error plus a letter which is the position where the error started. Two spaces and one letter equals to 3 columns. Therefore, you have an error that is located in the 3rd column.
In your case, the error is located at the row 104 and there are 13 symbols/spaces/letters or numbers before the command that introduces the error. Everything before column 14 is correct. The error starts at column 14.

How to read a specific part of a line in a text document in VB 2010?

I'm trying to read a specific part of a text document which will allow me to allow the user into the program.
The problem i'm having with the code is that it is able to complete the first if statement but no the second - it reads the username but not the password.
Dim usernames() As String = File.ReadAllLines(Dir$("Usernames.txt"))
For RecordNumber = 0 To UBound(usernames)
If Trim(Mid(usernames(RecordNumber), 1, 15)) = TextBox1.Text Then
If Trim(Mid(usernames(RecordNumber), 15, 30)) = TextBox2.Text Then
MsgBox("Password is correct")
End If
End If
Next RecordNumber
Any help is greatly appreciated.
Thanks

I Have 2 1064 SQL Errors And Can Not Figure Them Out

This code worked good on ph 5.3. My server got upgraded to php5.6 and now the code no longer works.
Here is the two statements.
$sql = "UPDATE " . FORUM_TOUR_TABLE . "
SET page_subject = '$subject', page_text = '$message', page_access = $page_access
WHERE page_id = $id";
It says :
`SQL Error : 1064 Syntax error near 'WHERE page_id = 1' at line 3
UPDATE SET phpbb_forum_tour page_subject = ' Welcome To The Tower' , page_text = ' Update me please ' = WHERE page_access page_id = 1
Line : 172
File: admin_forum_tour.php`
That happens when I try to update a post.
When I try to add a new post using this code:
$sql = "INSERT INTO " . FORUM_TOUR_TABLE . " (page_id, page_subject, page_text, page_sort, bbcode_uid, page_access)
VALUES ($id, '$subject', '$message', $page, '$bbcode_uid', $page_access)";
This gives me this:
`SQL Error : 1064 Syntax error near ')' at line 2
INSERT INTO phpbb_forum_tour ( page_id , page_subject , page_text , page_sort , bbcode_uid , page_access ) VALUES (3, '2 Word Rule ', ' Hello World I am here ', 30 , ' f4e1be18dc ' )
Line : 198
File: admin_forum_tour.php`
I 100% apologize for asking this as I am more than sure it has been beat to death. I have been searching for a couple hours now and have all but given up. I had it working once but was told I opened my self up to injection. I am not a pro coder. I get lucky sometimes and make things work. I am sure these errors and code is basic to most but I am still learning.
Thanks for helping and understanding my "newbieness".

CT_FETCH error in PowerBuilder Program

I'm still learning PowerBuilder and trying to get familiar with it. I'm receiving the following error when I try to run a program against a specific document in my database:
ct_fetch(): user api layer: internal common library error: The bind of result set item 4 resulted in an overflow. ErrCode: 2.
What does this error mean? What is item 4? This is only when I run this program against a specific document in my database, any other document works fine. Please see code below:
string s_doc_nmbr, s_doc_type, s_pvds_doc_status, s_sql
long l_rtn, l_current_fl, l_apld_fl, l_obj_id
integer l_pvds_obj_id, i_count
IF cbx_1.checked = True THEN
SELECT dsk_obj.obj_usr_num,
dsk_obj.obj_type,
preaward_validation_doc_status.doc_status,
preaward_validation_doc_status.obj_id
INTO :s_doc_nmbr, :s_doc_type, :s_pvds_doc_status, :l_pvds_obj_id
FROM dbo.dsk_obj dsk_obj,
preaward_validation_doc_status
WHERE dsk_obj.obj_id = :gx_l_doc_obj_id
AND preaward_validation_doc_status.obj_id = dsk_obj.obj_id
using SQLCA;
l_rtn = sqlca.uf_sqlerrcheck("w_pdutl095_main", "ue_run_script", TRUE)
IF l_rtn = -1 THEN
RETURN -1
END IF
//check to see if document (via obj_id) exists in the preaward_validation_doc_status table.
SELECT count(*)
into :i_count
FROM preaward_validation_doc_status
where obj_id = :l_pvds_obj_id
USING SQLCA;
IF i_count = 0 THEN
//document doesn't exist
// messagebox("Update Preaward Validation Doc Status", + gx_s_doc_nmbr + ' does not exist in the Preaward Validation Document Status table.', Stopsign!)
//MC - 070815-0030-MC Updating code to insert row into preaward_validation_doc_status if row doesn't already exist
// s_sql = "insert into preaward_validation_doc_status(obj_id, doc_status) values (:gx_l_doc_obj_id, 'SUCCESS') "
INSERT INTO preaward_validation_doc_status(obj_id, doc_status)
VALUES (:gx_l_doc_obj_id, 'SUCCESS')
USING SQLCA;
IF sqlca.sqldbcode <> 0 then
messagebox('SQL ERROR Message',string(sqlca.sqldbcode)+'-'+sqlca.sqlerrtext)
return -1
end if
MessageBox("PreAward Validation ", 'Document number ' + gx_s_doc_nmbr + ' has been inserted and marked as SUCCESS for PreAward Validation.')
return 1
Else
//Update document status in the preaward_validation_doc_status table to SUCCESS
Update preaward_validation_doc_status
Set doc_status = 'SUCCESS'
where obj_id = :l_pvds_obj_id
USING SQLCA;
IF sqlca.sqldbcode <> 0 then
messagebox('SQL ERROR Message',string(sqlca.sqldbcode)+'-'+sqlca.sqlerrtext)
return -1
end if
MessageBox("PreAward Validation ", 'Document number '+ gx_s_doc_nmbr + ' has been marked as SUCCESS for PreAward Validation.')
End IF
update crt_script
set alt_1 = 'Acknowledged' where
ticket_nmbr = :gx_s_ticket_nmbr and
alt_2 = 'Running' and
doc_nmbr = :gx_s_doc_nmbr
USING SQLCA;
Return 1
ElseIF cbx_1.checked = False THEN
messagebox("Update Preaward Validation Doc Status", 'The acknowledgment checkbox must be selected for the script to run successfully. The script will now exit. Please relaunch the script and try again . ', Stopsign!)
Return -1
End IF
Save yourself a ton of headaches and use datawindows... You'd reduce that entire script to about 10 lines of code.
Paul Horan gave you good advice. This would be simple using DataWindows or DataStores. Terry Voth is on the right track for your problem.
In your code, Variable l_pvds_obj_id needs to be the same type as gx_l_doc_obj_id because if you get a result, it will always be equal to it. From the apparent naming scheme it was intended to be long. This is the kind of stuff we look for in peer reviews.
A few other things:
Most of the time you want SQLCode not SQLDbCode but you didn't say what database you're using.
After you UPDATE crt_script you need to check the result.
I don't see COMMIT or ROLLBACK. Autocommit isn't suitable when you need to update multiple tables.
You aren't using most of the values from the first SELECT. Perhaps you've simplified your code for posting or troubleshooting.

FilePut returns unhandled exception of type 'System.ArgumentException'

I am writing in Visual Basic on Visual Studio 2013.
I have defined the Customer record structure in a module. I am trying to save to a fixed length record. However, when I try and save it comes back highlighting FilePut with the error message:
"An unhandled exception of type 'System.ArgumentException' occurred in
Microsoft.VisualBasic.dll".
My code for the subroutine is below:
'Open customer file to find what ID to use
FileOpen("1", "CustomerRecord.dat", OpenMode.Random, OpenAccess.ReadWrite)
'Find length of customer file
Dim RecordLength As Integer = Len(Customer)
'Populate customer ID with algorithm to find unique ID to use (Last ID used + 1)
txt_CustomerID.Text = Str(LOF(1) / RecordLength + 1)
'Find record number to write
Dim RecordToWrite As Integer = (LOF(1) / RecordLength + 1)
'Populate all the customer variables with the corresponding
'textbox information
Customer.CusID = Int(txt_CustomerID.Text)
Customer.Title = cmb_Title.Text
Customer.Forename = txt_Forename.Text
Customer.Surname = txt_Surname.Text
Customer.Postcode = txt_Postcode.Text
Customer.NameNo = txt_HouseName.Text
Customer.Town = txt_Town.Text
Customer.DOB = txt_DOB.Text
Customer.TelNo = txt_TelNo.Text
Customer.Email = txt_Email.Text
FilePut("1", Customer, RecordToWrite)
FileClose(1)
How would I solve this problem?

Resources