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.
Related
Do you have any ideas how value which was writeback from SF to database could be returned from data base again to Spotfire input field.
(No just any value, what is mechanism stay behind it?)
If I need to make changes in this record ?
We writeback to DB with IronPython scripting assigning document properties.
Piece of code....
sqlIns = "INSERT INTO SCHEMA.TABLE_NAME (FIELD, WELL, WELLBORE, WELLTYPE) \n\
VALUES \n\
('" + Document.Properties["IFIELD"] + "', \n\
'" + Document.Properties["IWell"] + "', \n\
'" + Document.Properties["IWellBore"] + "', \n\
'" + Document.Properties["IWellType"] + "')"
print sqlIns
dbsettings = DatabaseDataSourceSettings( "System.Data.OracleClient","Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=server)(PORT=****))(CONNECT_DATA=(SERVICE_NAME=****)));User Id=;Password=",sqlIns)
ds = DatabaseDataSource(dbsettings)
newDataTable = Document.Data.Tables.Add("temp",ds)
Document.Data.Tables.Remove(newDataTable)
The problem is that before updating into the database the record, this record needs somehow modify. I insert the data through input or drop-down field in the text area, then press the Submit button to insert it into the database. It recorded there and appeared in the table which I add on the same page in SF.
My thoughts that it should be workflow like: highlight record you want to change (it happened in a table connected to SF)
-> once you choose the record, it appears in the input screen (input screen - text area where you enter all these values for the first time or another input screen only for data modification)
-> make required changes
-> re-write/update data to DB (with replacement initial record.)
The python script just sends an sql command. That command can be changed to do an update instead of an insert.
Post an example of code that you are using for the insert and people can assist on how to change to an update statement.
You'll need to have a primary key or other identifier for the update statement.
If you "wrote back to a database" to read the data into a input Field or table you'd have to query the database (a normal query to pull data into spotfire)
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.
I have two questions:
1. If we can pass an array to VBSCript using java. I am able to pass single variables to VBSCript using following command
Runtime.getRuntime().exec("wscript openChartsDevice.vbs " + fileName + " " + range);
But when I pass a String array, it says type mismatch. I am catching the array passed in
Dim arr()
any Suggestions?
Edit 1 Following question has been answered
2. I am using following Vbscript to create chart in excel
Dim oExl,excelPath,objWriteSheet,objWriteWorkbook
Dim oMychartProcs
Set oExl=CreateObject("Excel.Application")
Set objWriteWorkbook = oExl.Workbooks.Open("SomeExcelfile.xlsx")
Set objWriteSheet = objWriteWorkbook.Worksheets(1)
Set oMychartProcs = objWriteWorkbook.Charts.Add
oMychartProcs.SetSourceData objWriteSheet.Range(Cells(2,1),Cells(7,6))
oMychartProcs.ChartType = 4
oMychartProcs.Name = "ChartName"
oMychartProcs.Activate
I have given the range as A2:F7. when I enter
oMychartProcs.SetSourceData objWriteSheet.Range("A2:F7")
the chart is created perfectly but when I use the
Range(Cells(2,1),Cells(7,6))
whole excel sheet is converted to chart.
I want to provide the range through parameters so I want above formula to work. I've searched a lot and could not find a definitive way for it. Thank you.
You can not pass array as an object. But you can pass its elements as string parameters to the vbscript function with a space as the delimiter.
openChartsDevice.vbs " + fileName + " " + arg[0] + " " + arg[1] + " " + arg[2].....
You can a create a method in java to pass an array and return a string
arg[0] + " " + arg[1] + " " + arg[2].....
Another Approach: Create a file with input parameters. Update your VBScript to refer to that input file to get the parameters instead of looking for command line arguments.
I don't know JScript. But the way to get in VBScript the same thing.
For Each thing in Array()
A = A & thing & " "
Next
You are actually asking how to turn an array into a delimited string not a vbscript array.
See this article which your question title implies you are interested in.
http://blogs.msdn.com/b/ericlippert/archive/2003/09/22/53061.aspx
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.
I have created a class that will manage connection and commands, I named it DbConfiguration and it uses a Singleton pattern(using dbc as an object name).
My problem is this SQL syntax throws an error when I try to run ExecuteNonQuery()
Using this connection string:
"Provider=Microsoft.ACE.OLEDB.12.0;dbms.accdb;Persist Security Info=False"
I executed this first:
dbc.SetCommand("INSERT INTO inventory ([CallNumber], [Title], [ImageLocation]) VALUES (#CALLNUMBER, #TITLE, #IMAGELOC);");
dbc.GetCommand().Parameters.Add("#CALLNUMBER", System.Data.OleDb.OleDbType.VarChar, 255);
dbc.GetCommand().Parameters.Add("#TITLE", System.Data.OleDb.OleDbType.VarChar, 255);
dbc.GetCommand().Parameters.Add("#IMAGELOC", System.Data.OleDb.OleDbType.VarChar, 255);
dbc.GetCommand().Parameters["#CALLNUMBER"].Value = txtCallNumber.Text;
dbc.GetCommand().Parameters["#TITLE"].Value = txtTitle.Text;
dbc.GetCommand().Parameters["#IMAGELOC"].Value = (!moveto.Equals("db_storage\\") ? moveto : "db_storage\\no_img.png");
and followed by:
dbc.GetCommand().ExecuteNonQuery();
Next is I executed this code:
dbc.SetCommand("INSERT INTO publishing_info ([ID], [Author], [DateTime], [Publisher], [Pages], [ISBN_NO]) " +
"VALUES (" +
"SELECT([ID] FROM inventory " +
"WHERE inventory.CallNumber=#CALLNUMBER AND inventory.Title=#TITLE AND inventory.ImageLocation=#IMAGELOC), " +
"#AUTHOR, #DATETIME, #PUBLISHER, #PAGES, #ISBN);");
and also followed by:
dbc.GetCommand().ExecuteNonQuery();
Here are the parameters that I have used for your reference:
dbc.GetCommand().Parameters.Add("#AUTHOR", System.Data.OleDb.OleDbType.VarChar, 255);
dbc.GetCommand().Parameters.Add("#DATETIME", System.Data.OleDb.OleDbType.VarChar, 255);
dbc.GetCommand().Parameters.Add("#PUBLISHER", System.Data.OleDb.OleDbType.VarChar, 255);
dbc.GetCommand().Parameters.Add("#PAGES", System.Data.OleDb.OleDbType.UnsignedInt, 4);
dbc.GetCommand().Parameters.Add("#ISBN", System.Data.OleDb.OleDbType.VarChar, 255);
dbc.GetCommand().Parameters["#AUTHOR"].Value = txtAuthor.Text;
dbc.GetCommand().Parameters["#DATETIME"].Value = txtYear.Text;
dbc.GetCommand().Parameters["#PUBLISHER"].Value = txtPublisher.Text;
dbc.GetCommand().Parameters["#PAGES"].Value = uint.Parse(txtPages.Text);
dbc.GetCommand().Parameters["#ISBN"].Value = txtISBN.Text;
Here is the screenshot of my stack trace(I can't attach it because I only have 1 rep points)
http://i44.tinypic.com/2w49t84.png
What should I do to make the syntax work?
And also do I need to close the connection first before executing another query?
Update 1
I used DMax(\"[ID]\", \"inventory\") to retrieve the last ID but it returns all the fields of inventory and writes it all on the fields that it can be written to, in my C# code but if I write the query on MS Access 2010 it doesn't do what it does on a C# code. What seems to be the problem?
Update 2
Problem solved with dbc.GetCommand().Parameters.Clear()
You do not need to close the connection, but you do need to insert a left parenthesis in your sub-select:
dbc.SetCommand("INSERT INTO publishing_info ([ID], [Author], [DateTime], [Publisher], [Pages], [ISBN_NO]) " +
"VALUES (" +
"(SELECT([ID] FROM inventory " +
"WHERE inventory.CallNumber=#CALLNUMBER AND inventory.Title=#TITLE AND inventory.ImageLocation=#IMAGELOC), " +
"#AUTHOR, #DATETIME, #PUBLISHER, #PAGES, #ISBN);");