oledbcommand

SSIS - Updating a table with a OLE DB Command

纵饮孤独 提交于 2019-11-27 08:06:38
问题 I need to translate the next SQL Query in SSIS: (Each table belong to a different source - SQL Server & ORACLE) update A set A.col1 = B.col1 A.col2 = B.col1 from table A inner join table B B on A.col3 = Col3 where A.col4 = value 1 and A.col5 = value2 and B.col4 = value 3; As you can see, source and destination corresponds to the same source: table A. This is the work flow I have created. After the conditional split I have used a Derived Column in order to copy the column B.Col1 to use it on

insert into access database

一曲冷凌霜 提交于 2019-11-27 08:03:56
问题 i have trouble inserting data from textbox into ms access database, I get an error " Syntax error in INSERT INTO. " Can someone help me out please? here's the code: public void button1_Click(object sender, EventArgs e)//save { using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\productdb.mdb")) { OleDbCommand CmdSql = new OleDbCommand("Insert into [product](Kod, names, price,type,volume,manufacturer,importer) enter code here { conn

How to use SQL user defined functions in .NET?

依然范特西╮ 提交于 2019-11-27 03:24:29
问题 I created a scalar function in the DB SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER FUNCTION [dbo].[fn_GetUserId_Username] ( @Username varchar(32) ) RETURNS int AS BEGIN DECLARE @UserId int SELECT @UserId = UserId FROM [User] WHERE Username = @Username RETURN @UserId END Now I want to run it within my .NET C# or VB.NET code. I use Entity Framework, I tried to map it with function mapping and I did not success. i don't care to do it with simple DbCommand, the problem is that I get no

Is order of parameters for database Command object really important?

微笑、不失礼 提交于 2019-11-26 22:26:46
问题 I was debugging a database operation code and I found that proper UPDATE was never happening though the code never failed as such. This is the code: condb.Open(); OleDbCommand dbcom = new OleDbCommand("UPDATE Word SET word=?,sentence=?,mp3=? WHERE id=? AND exercise_id=?", condb); dbcom.Parameters.AddWithValue("id", wd.ID); dbcom.Parameters.AddWithValue("exercise_id", wd.ExID); dbcom.Parameters.AddWithValue("word", wd.Name); dbcom.Parameters.AddWithValue("sentence", wd.Sentence); dbcom

OleDbParameters and Parameter Names

夙愿已清 提交于 2019-11-26 19:04:38
I have an SQL statement that I'm executing through OleDb, the statement is something like this: INSERT INTO mytable (name, dept) VALUES (@name, @dept); I'm adding parameters to the OleDbCommand like this: OleDbCommand Command = new OleDbCommand(); Command.Connection = Connection; OleDbParameter Parameter1 = new OleDbParameter(); Parameter1.OleDbType = OleDbType.VarChar; Parameter1.ParamterName = "@name"; Parameter1.Value = "Bob"; OleDbParameter Parameter2 = new OleDbParameter(); Parameter2.OleDbType = OleDbType.VarChar; Parameter2.ParamterName = "@dept"; Parameter2.Value = "ADept"; Command

Storing an image into an Attachment field in an Access database

主宰稳场 提交于 2019-11-26 17:58:30
I'm writing a VB application where I need to store an image in the database. The user selects the image on their computer, which gives me the path as a string. Here's my attempt at it, however I'm getting the error "An INSERT INTO query cannot contain a multi-valued field." Here is my code: Dim buff As Byte() = Nothing Public Function ReadByteArrayFromFile(ByVal fileName As String) As Byte() Dim fs As New FileStream(fileName, FileMode.Open, FileAccess.Read) Dim br As New BinaryReader(fs) Dim numBytes As Long = New FileInfo(fileName).Length buff = br.ReadBytes(CInt(numBytes)) Return buff End

Why does a LIKE query in Access not return any records?

烂漫一生 提交于 2019-11-26 07:43:52
问题 Is there any reason why SELECT * FROM MyTable WHERE [_Items] LIKE \'*SPI*\' does not return any records with OleDbAdapter.Fill(DataSet) or OleDbCommand.ExecuteReader() ? When I run the same SQL in MS Access directly, it returns the expected records. Also, in the same code, if I change the SQL to SELECT * FROM MyTable all records are returned. 回答1: Change your * to % as % is the wildcard search when using OLE DB. SELECT * FROM MyTable WHERE [_Items] LIKE '%SPI%' 回答2: Try changing LIKE to ALIKE

OleDbParameters and Parameter Names

隐身守侯 提交于 2019-11-26 06:47:45
问题 I have an SQL statement that I\'m executing through OleDb, the statement is something like this: INSERT INTO mytable (name, dept) VALUES (@name, @dept); I\'m adding parameters to the OleDbCommand like this: OleDbCommand Command = new OleDbCommand(); Command.Connection = Connection; OleDbParameter Parameter1 = new OleDbParameter(); Parameter1.OleDbType = OleDbType.VarChar; Parameter1.ParamterName = \"@name\"; Parameter1.Value = \"Bob\"; OleDbParameter Parameter2 = new OleDbParameter();