|
Hello everyone,
I have a program which connects to an internet database(MySQL) using MyODBC. I am using the following code to write to "imagestorage" table in the "test" database. When I run this I get an Error message saying:
ERROR [HY000] [MySQL][MyODBC 5.00.11][MySQL] 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FileName, NULL,
ConStr = "DRIVER={MySQL Connector/ODBC v5};SERVER= XXXXXXXX; PORT=3306; DATABASE=; UID=XXXXXXX; PWD= XXXXXXXX; OPTION=3"; <br />
OdbcCon = new System.Data.Odbc.OdbcConnection(ConStr);<br />
OdbcCon.Open();<br />
<br />
OdbcCom = new System.Data.Odbc.OdbcCommand("USE test;", OdbcCon);<br />
OdbcCom.ExecuteNonQuery();<br />
<br />
OdbcCom.CommandText = "INSERT INTO imagestorage VALUES(NULL, ?FileName, NULL, NULL);";<br />
OdbcCom.Parameters.Clear();<br />
OdbcCom.Prepare();<br />
<br />
OdbcCom.Parameters.Add("?FileName", System.Data.Odbc.OdbcType.VarChar);<br />
OdbcCom.Parameters["?FileName"].Value = "Khoramdin";<br />
<br />
OdbcCom.ExecuteNonQuery();
Can someone be kind enough to tell me where I am going wrong?
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
You SQL statement doesn't specify the columns you want to update. You provide the values, but the statement does know which values go in which colums.
INSERT INTO table (columnName1, columnName2, columnName3, ...) VALUES (value1, value2, value3, ...)
|
|
|
|
|
How can i export data from sql table to a text file
|
|
|
|
|
All you have to do is open the table, read each record one at a time, then write each field value out in the format you want. It's usually done by seperating the fields with commas and enclsing strings in quote marks, or some other delimitter.
|
|
|
|
|
i have a listbox and when i select a item in the listbox i want this selected item to get information from the db and then show this data (that is related to the selected item) shown in seperated textboxes.
an example:
i choose a building from the listbox, when i select a building i want to retrieve the name of the building, adress, city and so on.. to be shown in their textboxes that is read only.
How can i do this? i have the db ready but dont know how to retrieve the data that is related to the selected item to be shown in their txtBoxes.
I really hope that someone could help me with this, i use C# as language and ms sql server.
|
|
|
|
|
Hi,
I have an access data base stored on a website, I would like to connect it via a windows application in C#. is it possible?
I tried the following without success:
this.oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"http:\\www.website.com\\DB\\DataBase.mdb \" ";
Thanks
|
|
|
|
|
Yes, but not in the way your connection string suggests. HTTP doesn't support what you're trying to do. In order to connect to an Access database, you have to have Read AND Write access to the file. HTTP will NOT allow this.
Access is a file-based desktop database that doesn't support any kind of TCP/IP based communication.
In order to get at this database, you have to do one of two things. Either expose the Windows Server to the Internet and the Share that exposes the folder the database is in. THIS IS A VERY FOOLSIH THING TO DO!
Or, you have to write a webservice that exposes all the database functionality you want. Yous external application would then have to call the webservice to do the work for your application.
|
|
|
|
|
what is exactly a web service? do you mean that I have to create a web service, who can use the database, and my application will use thw web service for connecting the database?
Can you please explain a little more your first suggestion? how can I share the Database?
Thanks in advance for your response.
|
|
|
|
|
lune12 wrote: Can you please explain a little more your first suggestion? how can I share the Database?
You'd be wiser to cover it in gas and throw a match on it.
lune12 wrote: do you mean that I have to create a web service, who can use the database, and my application will use thw web service for connecting the database?
Yes. There's a ton of articles and info on web services online.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
lune12 wrote: Can you please explain a little more your first suggestion? how can I share the Database?
As Dave said "THIS IS A VERY FOOLSIH THING TO DO!". So, don't do it. You expose yourself to all sorts of security issues. Issues you really don't want to have to deal with.
|
|
|
|
|
The table consists of 3 columns:
ID,Date,Value.
Sample Data:
ID Date Value
1 1/1/2004 243
2 1/1/2004 0
3 1/1/2004 32423
1 2/1/2004 2435
2 2/1/2004 545
3 2/1/2004 0
The above table holds transactions for last 3 months for each ID(from 1 to 1000).
It will have records till yesterday.
I need a query that return 5 rows for each ID having value >0.
The result might look like:
for ID=1:last 5 dates where value>0
for ID=2:last 5 dates where value>0
and so on.
Thanks in advance.
Or atleast is there any way to find the 2nd maximum along with group by.
Or atleast is there any way to combine "top" along with group by.
-- modified at 12:26 Saturday 19th May, 2007
Regards,
Arun Kumar.A
|
|
|
|
|
IMO, you can use GROUP BY...HAVING...you can get more info from SQL online book
<< >>
|
|
|
|
|
Thank you very much for your reply...
But still I am not able to find the exact answer.
Regards,
Arun Kumar.A
|
|
|
|
|
What have you tried so far?
try this...SELECT ... FROM...GROUP BY ID HAVING value > 0
<< >>
|
|
|
|
|
At last, I have found it:
SELECT A.* FROM
(
SELECT B.ID, B.Date,
RANK() OVER (PARTITION BY B.ID ORDER BY B.Date DESC) AS RowRank
FROM tblName B WHERE
B.Value>0 AND Date<CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)
GROUP BY
B.ID, B.Date
) A WHERE RowRank<=5 ORDER BY ID
Regards,
Arun Kumar.A
|
|
|
|
|
the best soultion is create a cursor and put cursor in stored procedure(SP) , finally call SP
-------------------------------
declare @vdd bigint
declare C1 cursor for Select distinct id from pdata
open C1
drop table #temsales
CREATE TABLE #temsales ( col1 bigint, col2 datetime, col3 bigint )
fetch next from c1 into @vdd
while @@fetch_status=0
begin
insert into #temsales select top 5 * from pdata where sales>0 and id =@vdd
fetch next from c1 into @vdd
end
close c1
deallocate c1
select * from #temsales
|
|
|
|
|
I mean a resource is created in a thread and now I want to access it from another thread.
|
|
|
|
|
Define "resource" in the current context.
|
|
|
|
|
Hai I am working with Sqlserver 2000, I want Syntax or a sample code for how to write user defined functions using Switch case statement in sql server 2000
Presently working in Esoft consulting ltd as .net developer
|
|
|
|
|
here is the syntax copied from SQL book online
Syntax
Simple CASE function:
CASE input_expression <br />
WHEN when_expression THEN result_expression <br />
[ ...n ] <br />
[ <br />
ELSE else_result_expression <br />
] <br />
END <br />
<br />
Searched CASE function:<br />
<br />
CASE<br />
WHEN Boolean_expression THEN result_expression <br />
[ ...n ] <br />
[ <br />
ELSE else_result_expression <br />
] <br />
END
and here is an example
<br />
USE pubs<br />
GO<br />
SELECT Category = <br />
CASE type<br />
WHEN 'popular_comp' THEN 'Popular Computing'<br />
WHEN 'mod_cook' THEN 'Modern Cooking'<br />
WHEN 'business' THEN 'Business'<br />
WHEN 'psychology' THEN 'Psychology'<br />
WHEN 'trad_cook' THEN 'Traditional Cooking'<br />
ELSE 'Not yet categorized'<br />
END,<br />
CAST(title AS varchar(25)) AS 'Shortened Title',<br />
price AS Price<br />
FROM titles<br />
WHERE price IS NOT NULL<br />
ORDER BY type, price<br />
COMPUTE AVG(price) BY type<br />
GO<br />
<br />
<< >><br />
|
|
|
|
|
Hi there,
Can any one direct me to documentation containing all the internal commands of SQL Server, please. I've used commands like Format in my sql statements with an Access DB, but SQL Server does not support Format as a function or command.
Thanks, Werries
A programmer's life is good... or is it?? Ek dink nie so nie!
|
|
|
|
|
|
|
Thanks for your reply, I appreciate it.
Regards, Werries
A programmer's life is good... or is it?? Ek dink nie so nie!
|
|
|
|
|
hello
i have written a program which connects to an internet database(mysql) using odbc. the program works fine on a system which is directly connected to the internet but fails to connect to the database on other systems in the lan.
Thank you
|
|
|
|