parameterized-query

How to parameterize widestrings using TADOCommand parameterized query?

故事扮演 提交于 2019-12-13 21:00:21
问题 i am trying to use a parameterized query with Delphi TADOCommand: var s: WideString; cmd: TADOCommand; recordsAffected: OleVariant; begin cmd := TADOCommand.Create(nil); cmd.Connection := Connection; cmd.CommandText := 'INSERT INTO Sqm(Filename) VALUES(:filename)'; s := AFilename; cmd.Parameters.ParamByName('filename').Value := s; cmd.Execute(); The resulting data in the database is complete mangled: C?:\U?s?er?s?\i??n?.A?V`A?T?O?P?I?A?\A?p?p?D??t??\L?o???l?\A?v?at??r? S?o?f?t?w?är¨? C?r??t?i

How to run parameterized query from VBA. Parameters sourced from recordset

南楼画角 提交于 2019-12-13 02:35:26
问题 I have a form where a user selects a vendor's name from a combobox, whose catalog file is to be imported. The combobox selection then drives a query to create a one-record recordset (rsProfile) containing several profile variables queried from a table of all vendor profiles. These variables are then used in a series of different queries to reformat, translate and normalize the vendor's uniquely structured files to a standardized format that can be imported into our system. I am frustrated

Strange behaviour of parameterized SQLite query

纵饮孤独 提交于 2019-12-12 11:24:34
问题 (Feel free to improve the question title if you can think of something better.) Question : Consider the following SQLite query: SELECT COUNT(*) FROM (SELECT 1 AS value UNION SELECT 2 AS value) WHERE value <= ? When I use 1 as the parameter, I expect the query to yield 1 , yet it yields 2 . Why does this happen? Additional information : This is a minimal working example to reproduce the issue (Android): Cursor c = db.rawQuery( "SELECT COUNT(*) " + " FROM (SELECT 1 AS value UNION SELECT 2 AS

Parameterized queries in sqlite3 using question marks

牧云@^-^@ 提交于 2019-12-12 06:26:35
问题 I am using sqlite3 module with Python and have this code so far. In the database I have stored daily weather conditions, and now I need my code to replace some rows with updated data. The code is supposed to be looking for the row with datetime value equal to new_data[0] . The way I parameterized the query is wrong, but cannot figure out the correct and most elegant way of going about it! new_data = ['12 Mar 2014', 'sunny', 20, 12] conn = sqlite3.connect(database_file) c = conn.cursor() c

SQL Server parameterized query with a WHERE clause with Nulls

允我心安 提交于 2019-12-11 23:47:14
问题 VB.NET 2012, ADO.NET, SQL Server 2014 I setup a parameterized query that works well. I essentially read records from a DataTable that comes from a different source than my SQL Server. It's small enough that I elected to read record by record and build a query and hit the SQL Server for a match. However I am having trouble getting a match when one of my fields is supposed to be matched for a null. I know a record exist because I can look at it in SQL Server directly and see it. With my

how to pass objects (byte array) in query if query is not parameterized?

不打扰是莪最后的温柔 提交于 2019-12-11 15:09:59
问题 I have this query to be run: string query = @"SELECT * FROM hint WHERE addedSessionId IN (x, y, z, ............)"; if (_connSource.State != ConnectionState.Open) _connSource.Open(); MySqlCommand cmd = new MySqlCommand(query, _connSource); MySqlDataReader r = cmd.ExecuteReader(); List<Hint> lstHint = new List<Hint>(); while (r.Read()) { Hint h = new Hint(Convert.ToInt32(r[0]), Convert.ToInt32(r[1]), Convert.ToString(r[2]), Convert.ToInt32(r[3]), Convert.ToInt32(r[4])); h.addedSessionId = (Guid

Querying a table in Excel with parameters using VBA

旧时模样 提交于 2019-12-11 11:56:27
问题 Below is the code I have to create a parameterized query in Excel. I am running MS Excel 2013. What I am doing is trying to connect to a SQL Server database. From here I want to query this database using a single cell where you type in a value of a column and it queries the database for all the rows in that column (a WHERE clause). This cell is supposed to be dynamic so when you change the value in it, it changes the result from the query. Here is the code I have Sub ParameterQueryExample() '

Ruby on Rails: Basic parameterized queries and URL formation

…衆ロ難τιáo~ 提交于 2019-12-11 07:28:41
问题 I'm trying to learn how to query a rails database and return the results as JSON. In my example, I want to query the data using the parameters, city and state. So far, in my controller, I have gotten the following action to work. def state @bathrooms = Bathroom.where("state = ?" ,params[:state]) respond_to do |format| format.json { render :json => @bathrooms } format.js { render :nothing => true } end end This is also my routing entry. match '/bathrooms/state/:state', :controller =>

mysql parameterized query in ASP.NET

江枫思渺然 提交于 2019-12-11 07:25:25
问题 i am working on parameterized queries but i am not getting proper query in result here is my code public MySqlCommand Get_Login(string clinetID, string loginID, string password, string branchID) { MySqlCommand objCommand = new MySqlCommand(this.Query); objCommand.Parameters.AddWithValue("@ClientID", clinetID); objCommand.Parameters.AddWithValue("@LoginID", loginID); objCommand.Parameters.AddWithValue("@Password", password); objCommand.Parameters.AddWithValue("@BranchID", branchID); objCommand

How big is an nvarchar(max) as far as ADO is concerned?

徘徊边缘 提交于 2019-12-11 01:15:42
问题 i am trying to use a parameterized query against ADO: INSERT INTO Foo (Name, Value) VALUES(@name, @value) In SQL Server the Name column is a varchar type. The Value column is an nvarchar(max) . What size do i pass when creating a parameter when i don't know, or want to specify, the size? procedure SaveTheThing(Connection: TADOConnection); var sql: WideString; cmd: _Command; begin sql := 'INSERT INTO Foo (Name, Value) VALUES(@name, @value)'; cmd := CoCommand.Create; cmd.Set_ActiveConnection