this code is in Textbox Change event.
dds.Tables["IncomeGenerator"].DefaultView.RowFilter = "' Income LIKE '" + txtSearch.Text + "' OR Expenses LIKE '" + txtSearch.Text + "' OR Date LIKE '" + txtSearch.Text + "' OR Balance LIKE '" + txtSearch.Text + "' OR Description LIKE '" + txtSearch.Text + "'";
when i run it, it gives a error saying " The expression contains an invalid string constant: '. "
can someone help me.
my Income, Expenses and Balance is Data Type Float and Date is Datetime. i hope it may help. can someone guide me with the mistake and help me
It's hard to tell for sure, but sometimes when I copy code from a web page or word processor, I inadvertently include a "book quote" (http://en.wikipedia.org/wiki/Quotation_mark_glyphs) that screws things up.
It looks like there may be some in the sample you posted. Try making sure all the quotes are the straight-up-and-down quotes, and not the begin-end "book quotes".
Related
I am creating a message inside a string using a Script task
The code would look like this:
Message = Description +"\n" + Message;
The idea is to receive a message like this:
Description
Description
and so on
Within a messagebox I can see this result, but when I open the mail, the message is composed of one single line:
Description1 Description2
I have also changed "\n" for "\n\r", Environment.NewLine. But it didn't work.
Could you explain me what am I doing wrong?
You need to typecast it as below:
(DT_STR,2,1252)"\r\n"
For example...the below expression in Execute SQL task is dynamic SQL
"INSERT INTO [dbo].[OBJ_COUNT]([OBJ_NAME], [OBJ_COUNT]) VALUES ( " + "'EMPLOYEE_MASTER', " + (DT_STR, 10, 1252) (#[User::EMP_MAST_COUNT])+" );" + (DT_STR,2,1252)"\r\n" + "GO " + (DT_STR,2,1252)"\r\n" + "INSERT INTO [dbo].[OBJ_COUNT]([OBJ_NAME], [OBJ_COUNT]) VALUES ( " + "'DEPT_MASTER', " + (DT_STR, 10, 1252) (#[User::DEPT_MAST_COUNT])+" );" + (DT_STR,2,1252)"\r\n"+ "GO "
And will give output as below...
INSERT INTO [dbo].[OBJ_COUNT]([OBJ_NAME], [OBJ_COUNT]) VALUES ( 'EMPLOYEE_MASTER', 2514);
GO
INSERT INTO [dbo].[OBJ_COUNT]([OBJ_NAME], [OBJ_COUNT]) VALUES ( 'DEPT_MASTER', 2541);
GO
Try "\n\n" . This works but adds an extra line break. In most cases it is adequate.
During a Value-Change inside a browse, my string value suddenly changes, specifically the string(9) will change to string(0).
sample:
in my combo-box, i used a list-item-pair with following code:
cb-name:LIST-ITEM-PAIRS = ?.
cb-name:DELIMITER = '?'.
FOR EACH employee WHERE employee.date-resigned = ? NO-LOCK BY employee.employee-no.
cb-name:ADD-LAST(TRIM(STRING(employee.employee-no, '99999999') + " - " + employee.last-name + ", " + employee.first-name + " " + SUBSTRING(employee.middle-name,1,1)) + ".",employee.employee-no).
END.
cb-name:SCREEN-VALUE = cb-name:ENTRY(1).
in the value-changed of browse:
ASSIGN cb-name:SCREEN-VALUE =
STRING(TRIM(STRING(employee.employee-no, '99999999') + " - " + employee.last-name + ", " + employee.first-name + " " + SUBSTRING(employee.middle-name,1,1)) + "." ,
STRING(employee.employee-no, '99999999')).
if the employee no has a string value of 9, progress will change it to 0.. producing an error message that has an invalid value..
ex: from 819001 /*correct*/ to 810001 /*incorrect*/
if there is no string(9), it will display like:818002
if i message the STRING(employee.employee-no, '99999999')), it will display the correct string value
Version doesn't matter in this case, apparently. I just simulated it in 10.2B08 using a temp-table with the named tables. The problem is when you're assigning the screen-value to the combo you're trying to convert the whole string (employee-no + names + separators) into format 99999999.
Since your combo is list-item-pairs
('Whatever I want it to display','the real value',
'and so on display' , 'and so forth value')
your solution is to assign the screen value just to the real value, disregard the label. In other words, as simple as changing your value-changed code to
ASSIGN cb-name:SCREEN-VALUE = STRING(employee.employee-no, '99999999') .
It worked for me. Let me know if you are still having trouble with it.
Good day,
Im getting an error (syntax error missing operator in a query expression for "and monitorNumber = Monit)
SQLDel = "DELETE FROM HBAU WHERE Peoplesoft ID ='" & PSID & "' and DATE =#" & InputDate & "# and MonitorNumber = Monit"
can anyone tell me whats missing...
If Monit is VBA variable, try this one:
SQLDel = "DELETE FROM HBAU WHERE [PeoplesoftID] =" & PSID & " and [DATE] =#" & InputDate & "# and [MonitorNumber] = " & Monit
also should Peoplesoft ID be PeoplesoftID? Note if your PeoplesoftID has numeric type, you don't need single quotes around PSID.
Aslo you may want to read this: Global Variables in SQL statement
I'm getting the following error:
HTTP Error 404.0 - Not Found The resource you are looking for has been
removed, had its name changed, or is temporarily unavailable
with the following code:
SqlConnection cn = new SqlConnection(#"Data Source=bpnaidu-pc\sqlexpress;Initial Catalog=UserLogIn;Integrated Security=True;Pooling=False");
cn.Open();
SqlCommand cmd = new SqlCommand( "INSERT INTO regd values('" + ddl_signup.Text + "','" + txt_user.Text + "','" + txtEmail1.Text+ "','" + txtPassword.Text + "','" + txtConPassword.Text + "')", cn);
cmd.ExecuteNonQuery();
Response.Redirect("welcome to "+txt_user.Text.ToString());
Response.Redirect("Home.aspx");
cn.Close();
Where is the problem?
Although the question isn't directly clear, the answer is. The problem is on this line:
Response.Redirect("welcome to "+txt_user.Text.ToString());
Response.Redirect sends a browser to the webpage specified in the parameter, so you're trying to send the browser to a page called "welcome to {...}". I find this unlikely. I suspect what you really want is:
Response.Write("welcome to "+txt_user.Text.ToString());
Response.Write just sends a text string straight into the HTTP output buffer.
However you follow this up immediately with a redirect to Home.aspx, so in reality the line actually does nothing as no sooner have you written the output out that you tell the browser to redirect to a different page, so the user will not see your welcome message.
I'd also like to point out that you're open to a SQL Injection attack as well - your line:
SqlCommand cmd = new SqlCommand( "INSERT INTO regd values('" + ddl_signup.Text + "','" + txt_user.Text + "','" + txtEmail1.Text+ "','" + txtPassword.Text + "','" + txtConPassword.Text + "')", cn);
...is open to a user doing bad things; if txt_user.Text contains the text '); drop table regd; there's a good chance you'll end up with a missing regd table. To fix, you need to use parameterised SQL statements. Rather than correct this here, I strongly recommend you follow up by reading Jeff Atwood's blog article about this and how to mitigate.
I have another problem with cassandra.. I have export a table in Mysql in .csv format and import it in Cassandra.the Mysql table contains filds date and time of types Date and Time. I define these fields as varchar in cassandra. so when I import the .csv file and execute the below query, it shows me an error:
my query:
ResultSet rs = stmnt.ExecuteQuery("Select * from station info where IDstation = 1011 and IDinfo = 18412:);
while (rs.next) {
System.out.println(rs1.getFloate(1) + " " +
rs1.getString(2) + " " +
rs1.getFloate(3) + " " +
rs1.getString(4) + " " +
rs1.getInt(5) + " " +
rs1.getInt(6) + " " +
rs1.getString(7) + " " +
rs1.getFloate(8));
}
the 7th field in print command is date..
and the error is:
java.lang.NumberFormatException: For input String: "6/2/1962"
at org.apache.cassandracql.jdbc.cassandraResultSet.getInt(CassandraResultSet.java:619)
at org.apache.cassandracql.jdbc.cassandraResultSet.getInt(CassandraResultSet.java:590)
I can not understand what it says... can anyone help me please?
Read what the stacktrace is telling you carefully
java.lang.NumberFormatException: For input String: "6/2/1962"
at org.apache.cassandracql.jdbc.cassandraResultSet.getInt(CassandraResultSet.java:619)
at org.apache.cassandracql.jdbc.cassandraResultSet.getInt(CassandraResultSet.java:590)
The error you are getting is to do with an attempt to retrieve a string as a integer.
Make sure that the date column is coming at 7th position only and not anywhere else. I suggest you to improve your query by specifying the column names. For eg.,
SELECT Col1, Col2... FROM Table
This avoids confusion of column order.