How to insert binary to SQL Express by VBA?
Hi all,
In the end of the post, there is my vba functions and query to create datatable. I got a run-time error message on the red line in the function. It says: [sql native client] string data right truncation. Did I do sometime wrong? Thanks for your time!
-L
Sub test()
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
Dim mConn As ADODB.Connection
'read the file data to bytes
'Specify stream type - we want To get binary data.
BinaryStream.Type = adTypeBinary
'Open the stream
BinaryStream.Open
'Load the file data from disk To stream object
BinaryStream.LoadFromFile file
Dim mCmd As ADODB.Command
Set mCmd = New ADODB.Command
With mCmd
' define query
.CommandText = "INSERT INTO TEST (FDATA) " & _
"VALUES (?)"
.CommandType = adCmdText
' add parameter
.Parameters.Append .CreateParameter("@P1", adVarBinary, _
adParamInput, BinaryStream.Size, BinaryStream.Read)
End With
' open db connection
mConn.ConnectionString = _
"Driver={SQL Native Client};Server=.\SQLEXPRESS;Database=XXXX;Trusted_Connection=yes;"
mCmd.ActiveConnection = mConn
'run-time error: [sql native client] string data right truncation
mCmd.Execute
mConn.Close
End Sub
GO
/****** Object: Table [dbo].[TEST] Script Date: 10/04/2007 11:06:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TEST](
[ID] [int] IDENTITY(1,1) NOT NULL,
[FDATA] [varbinary](max) NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
problem solved, I used wrong parameter type. Thanks for your time again.
Br,
L
Similar Messages
-
How can I Purge in SQL Express database?
For development purposes, we created a Hyper-V VM running Windows 7 with BizTalk Server 2010 installed running against a SQL Express database. We also installed Visual Studio (licensed) for map development.
Over time, the BizTalk tables grow, and are taking up way too much storage space.
I looked at the "Microsoft recommended" method of purging the BizTalk database/tables, but it requires enabling a DTA job in SQL Agent which is not available in SQL Express (as far as I know.)
How can I purge the BizTalk tables in SQL Express to reclaim storage space?
Since this is a development platform, I do NOT care about ANY historical data being retained, only "system" data (such as parties, etc.)
Thanks!!
Jim BarrYou can use the various cleanup scripts to purge the database. Details:
http://biztalkscheduledtask.codeplex.com/
Of course, you should not be using SQL Express. -
HOW TO INSERT DATA INTO SQL SERVER FROM MS ACCESS TABLE??
NEED TO INSERT DATA INTO SQL SERVER FROM MS ACCESS TABLE.
this is another method
http://www.mssqltips.com/sqlservertip/2484/import-data-from-microsoft-access-to-sql-server/
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to implement PL/SQL expression in Report conditonal?
Hi All,
In my application i am want use Pl/SQl as expression in Conditional Display for Report region. Can you please suggest me how to handle using PL/SQl expression in conditonal.
Thanks,
Anoo..In general terms, your PL/SQL expression should evaluate to true or false - true will display the region, false will hide it. It's analogous to writing the conditional expression part of an if statement.
So, if you had normal PL/SQL code that looks like this:
if :P999_MYPAGEITEM is null or :P999_MYPAGEITEM = 0 then
end if;The equivalent conditional pl/sql expression would simply be:
:P999_MYPAGEITEM is null or :P999_MYPAGEITEM = 0 Note: this is NOT the same as you would do for "PL/SQL body returning boolean Expression", which looks more like:
return :P999_MYPAGEITEM is null or :P999_MYPAGEITEM = 0;or
declare
bl_retval boolean;
begin
bl_retval := :P999_MYPAGEITEM is null or :P999_MYPAGEITEM = 0;
return bl_retval;
end; -
Entity DATE type attribute : Derieved From SQL Expression for date format
Hi,
I want to set one of the Entity's Date Attribute with specific format , for e.g DD-MM-YYYY
I see a Derieved From SQL Expression checkbox, how can I define the SQL Expression
can I use TO_DATE(EMP_START_DATE,'DD-MM-YYYY'), I want to insert a date in that format, when I am creating a row using viewObject.createRow()
Java Type is oracle.jbo.domain.Date which take YYYY-MM-DD as a string, I do not want to use this format
Thanks,Here is a solution, but I am sure it is not the best one. It will work in a hurry. Maybe you can create a helper method to generalize this conversion until something more succinct comes along for US:
This code assumes an import of jbo.oracle.domain.Date.
public void updateDateTest () {
AddressesViewImpl lVO = (AddressesViewImpl)this.getAddressesView1();
AddressesViewRowImpl lRow = (AddressesViewRowImpl)lVO.first();
System.out.println("create date for current record is currently: " +
lRow.getCreationDate());
java.util.Date today = new java.util.Date();
SimpleDateFormat dateFormat =
new SimpleDateFormat("dd-MM-yyyy");
SimpleDateFormat jboDateFormat =
new SimpleDateFormat("yyyy-MM-dd");
String lSampleDateString = "15-04-2010";
java.util.Date lSampleDate = null;
try {
lSampleDate = dateFormat.parse(lSampleDateString);
} catch (ParseException e) {
System.out.println("Parsing exception thrown: " + e.getMessage() +
"\n ==> caused by \n==>"+ e.getCause().getMessage());
lRow.setCreationDate(new Date(jboDateFormat.format(lSampleDate)));
System.out.println("about to commit; create date for current record is currently: " +
lRow.getCreationDate());
this.getDBTransaction().commit();
System.out.println("resetting to some other date; create date for current record is currently: " +
lRow.getCreationDate());
lRow.setCreationDate(new Date(jboDateFormat.format(today)));
this.getDBTransaction().commit();
}I defined this code in my Application Module Impl file and ran it with the BC tester. Here was its output:
Mar 18, 2010 8:27:54 AM oracle.jbo.jbotester.MainFrame main
INFO: BC4J Tester started.
Source breakpoint occurred at line 66 of FusionExperimentsAMImpl.java.
create date for current record is currently: 2009-02-02 12:09:54.0
about to commit; create date for current record is currently: 2010-04-15
resetting to some other date; create date for current record is currently: 2010-04-15I spent a little time looking around the forum for additional solutions. I think several years ago I even wrote a blog entry on this subject. If I remember how to do this right I will amend with more information. -
I Have the following interface in oracle data integrator
http://i44.tinypic.com/2mrsmxt.png
# it execute successfully before inserting the following expression
In the mapping I insert the following SQL expression to get the average when the quantity is 0
AVG(
CASE WHEN TEST.QUN = 0 THEN
(SELECT TEST.QUN FROM TEST
WHERE TEST1.PRUDU=TEST.PRUDU
AND TEST1.FLOW=TEST.UNIT
AND TEST1.UNIT=TEST.UNIT
AND to_char(TEST.DATEDDD,'MON')= to_char(TEST1.DATEDDD,'MON')
AND TEST1.DATEDDD !=TEST.DATEDDD
GROUP BY TEST.QUN
ELSE TEST.QUN
END)
when I check this expression in ODI ..
# the sql expression is correct for this RDMS
when I executed the interface i get this error
Caused By: java.sql.SQLSyntaxErrorException: ORA-00937: not a single-group group function
any idea ?I changed the code a little ..
CASE WHEN TEST.QUN = 0 THEN
(SELECT AVG(TEST.QUN) FROM TEST
WHERE TEST1.PRUDU=TEST.PRUDU
AND TEST1.FLOW=TEST.FLOW
AND TEST1.UNIT=TEST.UNIT
AND to_char(TEST.DATEDDD,'MON')= to_char(TEST1.DATEDDD,'MON')
AND to_char(TEST.DATEDDD,'YYYY')!= to_char(TEST1.DATEDDD,'YYYY')
ELSE TEST.QUN
END
And I get this error ..
ORA-01427: single-row subquery returns more than one row tips.
The TEST Table from the source and TEST1 is a lookup table because I couldn't do the alais in ODI
In sql developer I did the following code that will do the same thing and work successfully ..
update test B
set B.qun=
(SELECT AVG(TEST.QUN) FROM TEST
WHERE TEST.FLOW=B.UNIT
AND TEST.UNIT=B.UNIT
AND TEST.PRUDU=b.prudu
AND TEST.FLOW=b.flow
AND to_char(TEST.DATEDDD,'MON')= to_char(B.DATEDDD,'MON')
AND to_char(TEST.DATEDDD,'YYYY')!= to_char(B.DATEDDD,'YYYY')
where B.qun=0;
any help ?
thanksssss
naif .. -
Install Both SQL Express 2012 & LocalDB on Same Dev PC?
Q. How do I install both SQL Express 2012 & LocalDB 2012 on the same development PC?
I tried running the LocalDB 2012 Wizard installer and it failed because I have a 'Higher Version' of SQL Express installed.
I currently cannot run a web app using LocalDB unless I 'Attach' the database file in SQL Express 2012.Hi, you should be able to install both Express and LocalDB on the same machine. Can you run the discovery report to show exactly what is on your machine from a SQL Server perspective? Also, which version of Express and which version of LocalDB
are you trying to install?
Thanks,
Sam Lester (MSFT)
My Blog
This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click
"Mark as Answer" and
"Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread. -
Cant edit sql expression in crystal reports XI
when i right click on a sql expression it tries to log into the repository (which we dont use)..
If I actually log into the repository, the sql expression code still isnt there..
how do I edit my sql expressions..Hi Shanon,
If the report is saved to your Business Objects server then the report would prompt for log on repository.
If the report is saved to your desktop and your database is available then it wont prompt you.
Thanks,
Naveen. -
SQL Expression for date conversion - version XI
I am trying to convert a number field to a date field in order to use it in a date parameter in Infoview. The database field is in a 15 digit DTM format but is stored as a number. There is also a zero stored in the database field. When I try to create the date SQL Expression I get this error: Error in compiling SQL Expression: Failed to retrieve data from the database. Details: ORA-01840: input value not long enough for date format. How can I get the SQL Expression to not look at the zero? I tried putting a statement in my Record Selection to not pull any zero fields but that doesn't work. Any ideas? Thanks! Kelley
Hi Kelly,
It's been a while since I used Info View, so if it's about registering, etc. I won't know the
answer.
Did you link it ? Have you tested that it should even return data ?
Check the filtering, etc in a query builder to make sure.
Have you tested the sub report by running it by itself ? (just add a value to the parameter
field request)
Do you have suppression formulas in the sub report ?
Is the section of the main report that is holding the sub report
free of "suppresion" formulas ? -
Help with an SQL Expression - Return field value where Datetime is Min or First datetime
Hello,
I'm extracting results for a patient population.
I have 6 SQL expressions that pull back the first date for specific procedures or Medications being ordered.
These Expressions work perfect - One of the expressions return the first time a lab was ordered.
I'm using SQL that return
Min(OrderDatetime)
From OrderTable
Where
LABCode = XXX
I've now been ask to return the value of this lab result.
Question: How do I write an SQL expression that return the Lab value of the Min(OrderDatetime)
Example Data
PATID* LABID * OrderDatetime * ResultValue
Pat1*133 * 12/12/2013 11:00:pm * 77
Pat1*145 * 12/12/2013 11:45:pm * 45
Pat1*147 * 12/13/2013 12:10:AM * 78
I was to return 77
Thanks
SteveHere is what I came up with but I'm getting an error -
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <,>,>= or when the subquery is used as an expression.
Any thoughts on what I'm doing wrong?
SELECT LABRESULTS.ORDER_VALUE as LabResult
FROM LABRESULTS, ORDERS_PROD, PATIENT_HSP
WHERE
"ORDERS_PROD"."CSN_ID" = "LABRESULTS"."CSN_ID" AND
"ORDERS_PROD"."ORDER_PROC_ID" = "LABRESULTS"."ORDER_PROC_ID" AND
ORDERS_PROD.ORDER_INST IN (
SELECT Min(ORDERS_PROD.ORDER_INST)
FROM ORDERS_PROD
WHERE "PATIENT_HSP"."CSN_ID" = "ORDER_PROD"."CSN_ID" AND
("ORDERS_PROD"."ORDER_STATUS_C"<>4 OR
"ORDERS_PROD"."ORDER_STATUS_C"<>9) AND
"ORDERS_PROD"."FUTURE_OR_STAND" IS NULL AND
"ORDERS_PROD"."REASON_FOR_CANC_C" IS NULL AND
("ORDERS_PROD"."PROC_CODE" = 'LAB7764' OR
"ORDERS_PROD"."PROC_CODE" = 'LAB7765' OR
"ORDERS_PROD"."PROC_CODE" = 'LAB7766' OR
"ORDERS_PROD"."PROC_CODE" = 'LAB7767') -
I guess I really have 2 questions.
I am moving an application from Sybase over to SQL Server. I have created all of my tables. I have also created Scalar-value functions to return a total of a column from a child table based on a value from a master table. The reason I have done this I have multiple child tables that I want to return total on and I would have ahd to create subreports to retreive these totals.
My question first is "How do you call an SQL Expression and could some on show me the code"?
Second question is if I wrote a command to retrieve this scalar-value how would I pass the parameters?
Finally, I guess there were three questions <g>, Should I just go ahead and write the View over in SQL Server and use that for my report?Please re-post if this is still an issue or purchase a case and have a dedicated support engineer work with your directly.
Also please post one question per post so others can use the answers. SQL Expressions are ODBC driven. If the ODBC driver doesn't have the function from DB to DB then you won't be able to use them between DB's you support. -
How to change sql expression of SQL-Calculated Attribute of view object ?
Hi
jdev 11.1.1.5
I have a view object with a SQL-Calculated Attribute (sumAnalytic) how can I change sql expression of this attribute in runtime?
for example in application module method??Hi Mr Timo
Thanks for your reply but I do not need dynamic vo because I can not change all of my vo
I only need to change expression of SQL-Calculated Attribute of view object in run time.
For this I set expression in view object something like this 'select 2 from dual' and in run time in my AM method I get the vo query and replace 'select 2 from dual' with something like 'selet sum(amnt) over (partition by 1)' and set new query.
But I think the better solution must exist
Thanks -
*Urgent*How to insert data from MS SQL to the table that create at the adobe form?
Hi,
I'm using Adobe life cycle designer 8 to do my interactive form. I would like to ask how to insert data from MS SQL to the table that i have created in my adobe interactive form?
I really need the information ASAP as i need to hand in my project by next week... i really appreciate any one who reply this post.
ThanksTou need to do a couple of things
1. On the Essbase server, set up an odbc system connection to your MySQL database
2. In the load rule , go to the file menu and select open SQL data source and in the data source put in your SQL statement . A couple of hints. Where it says Select, don't put in the word select and where it say from don't put in from. The system adds them for you. The easiest way ti enter a SQL statement is to do it all in the select area So if your SQL would normanlly say select * from mytable just enter the code as * from mytable in the select area
The click ol/retrieve and enter in your connection info. Itshould bring data back into the load rule. Save the load rule and use it -
How to insert date into ms access database using sql query in servlet
sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
or either the system date is inserted with query .
plz help me
thanxbhavishya wrote:
sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
or either the system date is inserted with query .
plz help me
thanxAnd that SQL statement is another reason to use PreparedStatement. I assume bname and sname are input from some form? Well, if that's the case, simply inserting them into SQL by simple String concatenation is just begging for all sorts of problems. What if there is an apostrophe in the entry? Broken Statement. Worse, it's a wide open invitation to an SQL Injection attack. -
SQL Loader-How to insert -ve & date values from flat text file into coloumn
Question: How to insert -ve & date values from flat text file into coloumns in a table.
Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
How to load such values in columns of database using SQL Loader?
Please guide.Question: How to insert -ve & date values from flat text file into coloumns in a table.
Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
How to load such values in columns of database using SQL Loader?
Please guide. Try something like
someDate DATE 'DDMMYYYY'
someNumber1 "TO_NUMBER ('s99999999.00')"
someNumber2 "TO_NUMBER ('99999999.00s')"Good luck,
Eric Kamradt
Maybe you are looking for
-
Dear community, I have a flat data set which I run through a lookup and return. I want to check if at least one of the records matching a unique key constraint had a successful return without merging all the records. Can some one point me in the righ
-
Works as an application but not an applet
I have a swing program that works perftectly fine if ran from the command prompt as an application, but once it is run as an applet through a browser some parts are not working. i have narrowed it down to the following lines of code that are the culp
-
New Nikon 50mm AF-S 1.8
Nikon is releasing this lens tomorrow. Amazon and other retailers were offering pre-sales. I can't find anything about whether Best Buy will be carrying this lens or not. I had collected gift cards to best buy in order to purchase the nikon 35mm lens
-
CANVAS WINDOW OVERTOPPING ALL OTHER WINDOWS IN FCP
Hi All During editing I notice my canvas window blown up and take over the entire 20" screen. The only way to get all windows back on desktop is tput the mouse all the way to the top of the screen and click on the menu bar. All the window will pop up
-
I cant register in itunes "your payment methode declimed"
what i must to do to register in itunes ? im sure that my debit card is ok i dont have credite one. Its from US im in US and fill all the information and nothing pls help me