|
Okay so I am a complete noob to mysql.
I am trying to run the following statements in mysql query browser
DROP TABLE IF EXISTS `bedbugs`.`airports`;
CREATE TABLE `bedbugs`.`airports` (
`city` char(20) default NULL,
`country` char(20) default NULL,
`name` char(20) NOT NULL default '',
PRIMARY KEY (`name`)
);
basically two different queries through one query window.
I get the following error:
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 ';
CREATE TABLE `bedbugs`.`airports` (
`city` char(20) default NULL,
`cou' at line 1
Can someone explain what is going on. If I comment out either query - the other one runs fine (basically I can run one at a time).
Is this some sort of limitation of the query browser?
thanks in advance
|
|
|
|
|
-- =============================================
-- Create table basic template
-- =============================================
IF EXISTS(SELECT name <br />
FROM sysobjects <br />
WHERE name = N'<table_name, sysname, test_table>' <br />
AND type = 'U')<br />
DROP TABLE <table_name, sysname, test_table><br />
GO<br />
<br />
CREATE TABLE <table_name, sysname, test_table> (<br />
<column_1, sysname, c1> <datatype_for_column_1, , int> NULL, <br />
<column_2, sysname, c2> <datatype_for_column_2, , int> NOT NULL)<br />
GO
I beleive you cannot drop or create two table in 1 statement.
Try the template above.
|
|
|
|
|
Hello guys,
Can anybody give me a link of a website , where is well explained how to
edit , delete and add records in a *.mdb dadatase file.
Or any good tutorial on how to use CDaoDatabase class
I have a MFC Dialog Based Application
And I am using Visual Studio.Net 2003
Thanks in advance
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 12:24 Monday 24th October, 2005
|
|
|
|
|
mdb database files are also known as Access databases. You could try this link http://www.codeproject.com/cs/database/csharpaccessdb.asp[^] or any other article present in the C# Database Section[^].
Basicly you can handle that type of database trough OleDb or Odbc in the same ADO.NET manner but using diferent implementations...
I hope you understand...because is a rough world out there...
|
|
|
|
|
thanks , but I need to implement it in C++
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
hello..
I'm using MYSQL and have a table with two fields :tag_in and time_in, where time_in is a timestamp field..
Some rows have the same value for tag_in.. I'd like to neaten up the database in 2 ways:
1. Delete rows with duplicate tag_in but removing the one with the oldest timestamp value
2. Delete rows with duplicate tag_in but removing the one with the latest timestamp value
how can i go about this please ?
|
|
|
|
|
Get the minimum - select min(tag_in)
Get the maximum - select max(tag_in)
|
|
|
|
|
thanks for the reply.. but that just gives me one value of tag_in which is the smallest out of the whole table.. or am i overlooking something ??
|
|
|
|
|
if (
select count(*) as EmtCnt from dtemdt where emdtactive = 0<br />
and datediff('d',dtetime,getdate()) > 1 )
begin
--delete from dtemdt where emdtactive = 0 and datediff('hh',dtetime,getdate()) > 24
end
Please tell me the error, I can't figure it out.
|
|
|
|
|
What is the error message - or what is the result set you are getting compared with the result set you expected to get?
Also, you may like to look into IF EXISTS (SELECT * FROM ....) it is faster than using COUNT(*) especially if there is a large amount of data.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Error Message after running the SQL from SQL analyzer
Server: Msg 1023, Level 15, State 1, Line 2
Invalid parameter 1 specified for datediff.
|
|
|
|
|
Don't put the d inside apostrophes
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
I want to develop a "multi datasource type" application (an aplication that should be able to querry more than one sql sever type - dbase, mysql, mssql, acces, excel)
Implementing my own communication drivers for dbase, acces, excel, and so on..., would be a waste of time in my opinion.
So my first question comes about an speed issue : whitch is faster, ado.net's odbc or ado.net's oledb? Meaning that the datasources I am facing are not at all small, having at least 30k rows (in the most favorable cases).
And the second question is about programatically driver detection : whether I use oledb or odbc, how can I find out progamatically if on a certain system the drivers neaded for a datasource type are present?
Thanx.
I hope I understand as quick as possible...because is a rough world out there...
|
|
|
|
|
Hi,
don't use ado.net odbc or ado.net oledb. U should use a managed provider for very database.
.NET 2.0 provides a buid-in ProviderFactory.
<br />
DbProviderFactory prov = DbProviderFactories.GetFactor("System.Data.SqlClient");<br />
DbConnection conn = provider.CreateConnection();<br />
conn.ConnectionString = CONNECTIONSTRING;<br />
conn.Open();<br />
If you want to use another database you should replace "System.Data.SqlClient".
'A programmer ist just a tool which converts caffeine into code'
|
|
|
|
|
Thank you for your advice, but my target is not .net v2.0.
I intend to build the application in .net v1.1.
The truth is that now I plan to build my own db factory, but I still don't know the answers to my initial questions...
I hope I understand...because is a rough world out there...
|
|
|
|
|
The fastest way is to use the speciallist classes for each database type. DotNetNuke implements its own data prodiver pattern you could look at for an example. Esentially there is an abstract base class and there are various concrete classes which use the appropriate specialist classes. To the user of the data provider there is no outward distinction between - it could as easily be calling Access as SQL Server. The results are returned as scalar values (int, bool, string, etc.) or through the IDataReader interface - so there is no need to know that is is an OleDbDataReader or SqlDataReader as they all expose the same interface.
Does this help?
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
You are right...
There are special clases designed especially for certain types of databases... these are the fastest...
T
he problem was that when no driver like the ones I wrote before are present, whitch is the best approch, Odbc or OleDb? The answer in most cases (if not all) is OleDb - a faster approach to databases..
Now another question still remains...
How can I find out programatically if a certain OleDb (or even Odbc) driver is installed - to be more specifically : how can I find out all the installed drivers?
I hope we understand...because is a rough world out there...
|
|
|
|
|
How can i use sql server for unicode supported language(urdu).As i insert records through query what it ends up
is just ?????
How to solve this problem.
|
|
|
|
|
Make sure you specify the correct collation when you install sql server
|
|
|
|
|
The font you are displying the results in doesn't support the characters you are putting in the database. Make sure your Windows settings and Sql Server settings are appropriate for displaying Urdu characters.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
I need an urgent solution if anyone can help me
How to export sql serve 2000 database to a csv format.
|
|
|
|
|
Create a DataTable, fill it with sql data and
...
Sub DataTable2CSV(ByVal table As DataTable, ByVal filename As String)
DataTable2CSV(table, filename, vbTab)
End Sub
Sub DataTable2CSV(ByVal table As DataTable, ByVal filename As String, _
ByVal sepChar As String)
Dim writer As System.IO.StreamWriter
Try
writer = New System.IO.StreamWriter(filename)
' first write a line with the columns name
Dim sep As String = ""
Dim builder As New System.Text.StringBuilder
For Each col As DataColumn In table.Columns
builder.Append(sep).Append(col.ColumnName)
sep = sepChar
Next
writer.WriteLine(builder.ToString())
' then write all the rows
For Each row As DataRow In table.Rows
sep = ""
builder = New System.Text.StringBuilder
For Each col As DataColumn In table.Columns
builder.Append(sep).Append(row(col.ColumnName))
sep = sepChar
Next
writer.WriteLine(builder.ToString())
Next
Finally
If Not writer Is Nothing Then writer.Close()
End Try
End Sub
|
|
|
|
|
Hello everyone, I am working on this project, and I want to convert a VARCHAR into a BIT using the CONVERT function, but I cannot find any examples of this. If anyone can help, I would very much appreciate it.
This is what my code looks like
[code]
DROP PROC insertfarminginformation
GO
CREATE procedure insertfarminginformation
@FirstName varchar(50),
@LastName varchar(50),
@Address varchar(100),
@Address2 varchar(100),
@City varchar(50),
@State char(5),
@Zip varchar(10),
@Dup varchar(1),
@CASS varchar(1),
@DPV varchar(1)
as
CONVERT(BIT,@Dup)
CONVERT(BIT,@CASS)
CONVERT(BIT,@DPV)
insert into Farming_Information values (@FirstName, @LastName, @Address, @Address2, @City,
@State, @Zip,@Dup, @CASS, @DPV)
GO
[/code]
Thanks,
The Major Rager
-- modified at 20:52 Friday 21st October, 2005
|
|
|
|
|
You need to assign the return of the CONVERT function to a variable:
Sample:
declare @Dup varchar(1)
set @dup='1'
declare @b bit
Set @b=convert(Bit,@Dup)
Select @b
|
|
|
|
|
I have loaded a datatable from a SQL database and have bound it to a customized(through vs.net, not code) datagridview, which has textboxcolumns, checkboxcolumns, and one comboboxcolumn. My problem is this: In order to actually interact with the combobox in any column, the user has to click 3 times. Near as I can figure, these 3 clicks account for 1) selecting the datagridviewcell, 2) selecting the combobox in the datagridviewcell, and thirdly, actually opening the combobox for editing. Is there any way to speed this up so a click (I know its in column 5 of the datagridview) opens the combobox? I've tried the _onCellContentClick event handler, with casting the sender as a datagridviewcomboboxcell, but I could not see any quick way of selecting the combobox inside. Any ideas?
|
|
|
|