|
Hi all,
Why wont my sql query work.
It returns with no records.
SELECT pkey, description
FROM Test
WHERE (((test.description) Like 'DEL%'))
Yet there is a record with 'DELIVER' in the description col of the Test table.
Tnx
|
|
|
|
|
Try testing it with the SQL builder
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Test your query in Query Analyzer.
By the way those parenthesis are extra
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
I have been trying to get some batch files to create and show tables details, but the only file I can get to work is one that populates a table;
i.e. load data local infile C:\\mysql\\data\\testDB\\data.sql"
I have created a few batch files as follows:-
File 1 (creatTest.sql)
CREATE TABLE Test(name varchar(15), price float(6,12)); and
File 2 (showTables.sql)
show tables; If I now try and run the showTables.sql batch file: e.g
mysql> source showTables;
I get error 2 if I miss out the path or
this gives the error Unknown command '\\' (for each '\\') if I use
mysql> source C:\\mysql\data\\mydb\\showTable.sql;
Is it possible to create/run batch files and are they any good examples (for Windows) please!
Does anyone have sample batch files to run for mySQL 4.1 in a Windows environment.
|
|
|
|
|
Are you saying that the SQL Server is on another machine, or the same machine?
You can generally specify a host name for the server, and your client having a static or dynamic IP is largely irrelevant, providing the name can be resolved (relies on either DNS or HOSTS lookup), and there is a network path available.
Is it possible that there's a firewall in the way which is blocking the SQL Server port?
Steve S
Developer for hire
|
|
|
|
|
Try to check the connection library[^] for the method that you should be connect to your SQL server database. On the other hand, your application should be able to give an opportunity for the user to type in the database server that you database reside on. This method could be reduce an error in your application.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hi,
I'm writing an windows application that access SQL SERVER database. But I have a problem when trying to run the program in a computer which has an internet connection with dynamic IP, it can't connect to the SQL database.
Is anyone have solutions for this problem?
thanks b4
|
|
|
|
|
i`m looking information about progress database, anybody ever use it? What kind of database is it? I`ve look it at google, but couldn`t find what I need. Thanks
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
|
Hi all,
Help – to be honest I’m not sure if this is an oracle question or a .net one, I am trying to invoke a job in my oracle 9i db from a web app. The job is created fine and runs fine when scheduled in oem. However I want to run the job from my vb.net web app. I have imported a dll, oemjobcreator, and invoked the Run command passing in what I believe to be the correct parameters but the job does not run. How do I invoke the job, or define the schedule from code? Has anyone tackled the problem of invoking oracle jobs from code?
Cheers,
Rob
|
|
|
|
|
I'm trying to insert a Hashtable in my database, and the way I found was first to serialize the Hashtable to a file before inserting the file (as a BLOB) into the database.
Is there a direct way to do this? That instead of going Object->File->BLOB, I can go from Object to BLOB directly.
Rafferty
|
|
|
|
|
Depends what your programming platform is. For instance, in C++ using OLE DB, you could serialise to an IStream object (or to memory and then create a stream on it), and use the IStream object directly from the provider...
Steve S
Developer for hire
|
|
|
|
|
oh yeah.. i'm using C#
I thought of a way that I'm not sure if it's going to work. This is how it goes:
- use the MemoryStream class
- Serialize the HashTable object to it using the BinaryFormatter.Serialize(...)
- Then convert this to type byte[] (the size of the byte array is based on the MemoryStream.Length <-- this is what I'm not sure of if this will work). Any feedbacks?
Thank you,
Rafferty
|
|
|
|
|
Can't help you, I'm afraid. I've used C++ almost exclusively for that kind of stuff. However, it sounds like it should work, since it's similar to what I've done. Presumably you have some way of writing arbitrary binary data to the db, specifying the data (your byte []) and the length, in which case, there's no reason to suppose it won't work.
Steve S
Developer for hire
|
|
|
|
|
I'll try to summarize what i did for inserting and for retrieving the BLOBs in a pseudo-code level...
object obj1;<br />
object obj2;<br />
object obj3;<br />
<br />
InsertData()<br />
{<br />
MemoryStream stream = new MemoryStream();<br />
BinaryFormatter formatter = new BinaryFormatter();<br />
<br />
Hashtable ht = new Hashtable();<br />
ht.Add( "Object1", obj1 );<br />
ht.Add( "Object2", obj2 );<br />
ht.Add( "Object3", obj3 );<br />
<br />
formatter.Serialize( stream, ht );<br />
<br />
int iStreamLength = Convert.ToInt32(stream.Length);<br />
byte[] byteBackup = new byte[iStreamLength];<br />
stream.Read( byteBackup, 0, iStreamLength );<br />
stream.Close();<br />
<br />
SqlConnection conn = new SqlConnection( strConnectionString );<br />
SqlCommand cmd = new SqlCommand( "ins_BackupData", conn );<br />
cmd.CommandType = CommandType.StoredProcedure;<br />
cmd.Parameters.Add( "@Name", "ObjectsBackup" );<br />
cmd.Parameters.Add( "@Data", byteBackup );<br />
<br />
cmd.ExecuteNonQuery();<br />
}<br />
<br />
RetrieveData()<br />
{<br />
SqlConnection conn = new SqlConnection( strConnectionString );<br />
SqlCommand cmd = new SqlCommand( "get_BackupData", conn );<br />
cmd.CommandType = CommandType.StoredProcedure;<br />
cmd.Parameters.Add( "@Name", "ObjectsBackup" );<br />
<br />
conn.Open();<br />
<br />
object obj = cmd.ExecuteScalar();<br />
<br />
if( obj != null )<br />
{<br />
byte[] byteBackup = (byte[])obj;<br />
MemoryStream stream = new MemoryStream(byteBackup);<br />
BinaryFormatter formatter = new BinaryFormatter();<br />
<br />
Hashtable ht = (Hashtable)formatter.Deserialize( stream );<br />
obj1 = ht["Object1"];<br />
obj2 = ht["Object2"];<br />
obj3 = ht["Object3"];<br />
<br />
stream.Close();<br />
}<br />
}
But in retrieving the data I'm getting this error, so clearly there's something wrong. I wonder if it's with the insertion or retrieval or both.
ERROR:
Binary stream does not contain a valid BinaryHeader, 0 possible causes, invalid stream or object version change between serialization and deserialization.
Any ideas? did I deserialize this incorrectly?
|
|
|
|
|
Hi
Frankly speaking, what ever one says, Microsoft technologies will always remain problem-matic.. specially with versions... they don have seamless integration. Deployment is always always an issue. But I still love .NET!! Anyway folks, my problem goes like this...
I am reading and updating excel sheet using ADO .NET.
Everything is working fine on machine, but on server it is all messing up...
I connect to sheet using the string called...
Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES;'
But whenver I try to execute insert command, following error occurs...
Operation must use an updateable query.Microsoft JET Database Engine at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at MyPledge.ClientPaymentData.Button1_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\Web1\Data.aspx.vb:line 74
I will highly appreciate if someone help me... !!!
eff_kay
-------------------
Therez No Place like ... 127.0.0.1
|
|
|
|
|
Hi
Presently i'm working in VB.Net with Oracle 9i as Backend. I need to
insert a bulk of records with two columns one as varchar and other as
number.Need to call a procedure with string array and number array as
input parameter, where i could go for inserting into Table instead of
calling reader from codebehind class as number of times the array length.
Thanks in advance for you replies
|
|
|
|
|
I am trying to import records in a Access Database. Each time I run this code, the records are added to my database, BUT it adds to the existing database. Example if I run code once, it imports 100 records, the next time I run the code again, it imports another 100 records. Now my Access database has 200 records, when it should only have 100 records. Can anyone help me on this? Thanks
Private Sub ImportToAccess()
Dim Con1 As New ADODB.Connection
Dim Con2 As New ADODB.Connection
Dim mySQL1 As String
Dim mySQL2 As String
Dim myDSN As String
Dim mySET As String
Dim tmpTable As String
'Connection parameters for Source Database
myDSN = "DSN=Springbrook1;UID=suresh;PWD=nissan;"
mySET = "set schema 'pub'"
mySQL2 = "select * from customer"
'Open Source Database
Con2.Open myDSN
Con2.Execute (mySET)
'Open Destination Database
Con1.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Temp\VB Sample Codes\mcwd\Connect Program\test1.mdb;" & _
"Jet OLEDB:Engine Type=5;"
'WORKS BUT CREATES DUPLICATE RECORDS
'mySQL1 = "INSERT INTO [C:\Temp\VB Sample Codes\mcwd\Connect Program\test1.mdb].[tblCustomer] SELECT Cust_No, First_Name FROM [odbc;DSN=Springbrook1;UID=suresh;PWD=nissan;].[Customer]"
Con1.Execute mySQL1
Con1.Close
Con2.Close
Set Con1 = Nothing
Set Con2 = Nothing
End Sub
|
|
|
|
|
If your intention is to replace the existing set of records with the new set, then execute a delete statement before executing your insert statement... something like this:
Con1.Execute "DELETE FROM tblCustomer"
|
|
|
|
|
Since the table has linked information, Can I not use any other SQL statement to update the information into my table. Using the delete statement will empty my table before importing new records. Any other ways to update instead of delete?
Thanks
|
|
|
|
|
Hi there. Well, sure, you could use the sql UPDATE statement to modify existing records. In your circumstance, you may wish to write code that selects the set of records from your source, then loop through that set issuing UPDATE statements for each record to modify the data.
|
|
|
|
|
Mike:
Does that mean I need a SELECT statement, than a loop to read records, and than a UPDATE statement to modify the records? How do I SELECT and read the records on temporary basis to compare the data?
|
|
|
|
|
I am trying to load very large amounts of data into a table (Access for now, SQL server later) from a C++/ADO application. There are about 200,000 rows consisting of 7 columns, all numbers. I have used the regular ADO RecordSet object AddNew method (~15 minutes), same but disconnecting and then reconnecting the RecordSet with a batch update (~5 minutes), and finally creating a SQL INSERT statement for direct execution (~5 minutes). I have removed most indexes on the database to facilitate insertions.
Is there a faster way to do this? Given that the computations to create the data only take 10 seconds, it seems like a waste to spend 15 minutes uploading it to a database.
Thanks
Mark Jackson
|
|
|
|
|
SQL should be a lot faster. And if network speed is a bottleneck consider running the application on the server.
SQL insert is not the fastest way of doing things. Consider looking into bulk insert methods.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
FWIW, I got around this by creating a huge buffer to hold the data, pasting it to the clipboard, and using a COM object to get Access to paste the data. It is ugly as it appears you cannot import the Access library due to bugs, so I used old-fashioned COM. It was worth the effort as program run time went from over 5 minutes to under 40 seconds.
Mark Jackson
void mrgVaRProdList::uploadList(void)
{
#define APPEND_LINE_SIZE 120
mrgDataSrc * ds;
mrgRecSet rs;
list<mrgVaRPoint *>::iterator iter;
int i;
unsigned long _l, counter;
Date bd, d1, d2;
CString str, buf;
char * chr;
size_t bufLen;
HGLOBAL h;
HWND wh = GetConsoleHWND();
ds = _mParent->getDataObj();
rs.setDataSrc(ds);
bd.setDate(_mParent->getAsOfDate());
str = bd.getDateStr();
i = (int)_uploadList.size();
bufLen = i * APPEND_LINE_SIZE;
h = GlobalAlloc(GHND, bufLen);
try
{
if (!OpenClipboard(wh))
{
throw("OpenClipboard");
}
if (!EmptyClipboard())
{
throw("EmptyClipboard");
}
rs.ExecSQL("Delete * from VaRData");
iter = _uploadList.begin();
counter = 1;
_l = 0;
chr = (char *)GlobalLock(h);
while (iter != _uploadList.end())
{
buf.Format("%u\t%s\t", counter, str);
buf.AppendFormat("%u\t%u\t", (*iter)->idOne, (*iter)->idTwo);
d1.setDate((*iter)->bukOne);
d2.setDate((*iter)->bukTwo);
buf.AppendFormat("%s\t%s\t", d1.getDateStr(), d2.getDateStr());
buf.AppendFormat("%f\t%f\t%f\r\n", (*iter)->rho, (*iter)->sigmaOne, (*iter)->sigmaTwo);
for (i = 0; i < buf.GetLength(); i++)
{
chr[_l] = buf.GetAt(i);
_l++;
}
counter++;
iter++;
}
GlobalUnlock(h);
if (SetClipboardData(CF_TEXT, h) == NULL)
{
throw("SetClipboardData");
}
CloseClipboard();
}
catch(_com_error e)
{
PrintADOError(_T("ADO Error mrgVaRProdList.uploadList() : "), &e);
}
catch(const char *c)
{
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
str.SetString((LPTSTR)lpMsgBuf);
LocalFree(lpMsgBuf);
cout << "Error in mrgVaRProdList.uploadList()-" << c << ":" << str.AllocSysString() << endl;
}
try
{
// our ID's
CLSID clsid;
IUnknown *pUnk;
IDispatch *pDisp;
IDispatch *pDispDoCmd;
DISPID dispid_DoCmd;
DISPID dispid_OpenTable;
DISPID dispid_RunCommand;
//parameter setup
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
OLECHAR FAR* szFunction;
// for getting/passing results
HRESULT hr;
VARIANT varResult;
// arguments for methods
VARIANT varArgs[1];
DISPPARAMS dpArgs;
BSTR bstrTemp;
CLSIDFromProgID(L"Access.Application", &clsid);
// Get an interface to the running instance, if any..
hr = GetActiveObject(clsid, NULL, (IUnknown**)&pUnk);
if (hr < 0)
{
// TODO - we need to start an instance
throw("Error GetActiveObject");
}
// Get IDispatch interface for Automation...
hr = pUnk->QueryInterface(IID_IDispatch, (void **)&pDisp);
if (hr < 0)
throw("Error QueryInterface - IID_IDispatch");
// Release the no-longer-needed IUnknown...
pUnk->Release();
szFunction = OLESTR("DoCmd");
hr = pDisp->GetIDsOfNames(IID_NULL, &szFunction, 1, LOCALE_USER_DEFAULT, &dispid_DoCmd);
if (hr < 0)
{
pDisp->Release();
throw("Error GetIDsOfNames for DoCmd");
}
hr = pDisp->Invoke(dispid_DoCmd, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
&dispparamsNoArgs, &varResult, NULL, NULL);
if (hr < 0)
{
pDisp->Release();
throw("Error Invoke for DoCmd");
}
pDispDoCmd = varResult.pdispVal;
szFunction = OLESTR("OpenTable");
hr = pDispDoCmd->GetIDsOfNames(IID_NULL, &szFunction, 1, LOCALE_USER_DEFAULT, &dispid_OpenTable);
if (hr < 0)
{
pDisp->Release();
pDispDoCmd->Release();
throw("Error GetIDsOfNames for OpenTable");
}
bstrTemp = ::SysAllocString(OLESTR("VaRData"));
varArgs[0].vt = VT_BSTR;
varArgs[0].bstrVal = bstrTemp;
dpArgs.cArgs = 1;
dpArgs.cNamedArgs = 0;
dpArgs.rgvarg = varArgs;
//Invoke the OpenTable Method
hr = pDispDoCmd->Invoke(dispid_OpenTable, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&dpArgs, NULL, NULL, NULL);
::SysFreeString(bstrTemp);
if (hr < 0)
{
pDisp->Release();
pDispDoCmd->Release();
throw("Error Invoking OpenTable");
}
szFunction = OLESTR("RunCommand");
hr = pDispDoCmd->GetIDsOfNames(IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT, &dispid_RunCommand);
if (hr < 0)
{
pDisp->Release();
pDispDoCmd->Release();
throw("Error GetIDsOfNames RunCommand");
}
varArgs[0].vt = VT_I2;
varArgs[0].iVal = 0x26; // acCmdPasteAppend
dpArgs.cArgs = 1;
dpArgs.cNamedArgs = 0;
dpArgs.rgvarg = varArgs;
hr = pDispDoCmd->Invoke(dispid_RunCommand, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&dpArgs, NULL, NULL, NULL);
// release interface pointers
pDispDoCmd->Release();
pDisp->Release();
}
catch(_com_error e)
{
PrintADOError(_T("ADO Error mrgVaRProdList.uploadList() : "), &e);
}
catch(const char *c)
{
cout << "Error in mrgVaRProdList.uploadList()-" << c << endl;
}
return;
}
|
|
|
|
|