|
Can anyone suggest me the line of codes and the data type of the field through which we can store files in an SQl Server Database through an ODBC Recordset
Samir Sood
|
|
|
|
|
You question is unclear. Please try again. Do you want to save binary data, i.e. "files", in a field in a SQL Server database? As far as the lines of code, you would use an INSERT statement to store new rows and an UPDATE statement to modify existing rows.
|
|
|
|
|
I want to store actual files i.e txt , rtf and doc files in the database .
Please Give the ines of code to insert and update them throgh odbc in MFC.
Samir Sood
|
|
|
|
|
You can store anything into BINARY database fields.
Read/Store the file to/from CLongBinary.
You can use CLongBinary variable in RFX_LongBinary for typed recordset.
Pavel
Sonork 100.15206
|
|
|
|
|
I want to send email from SQL server. Please tell me how? Do tell me complete procedure as how to make SQL server, an email client and what to do next ????
|
|
|
|
|
|
Just like this...
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo.p_SampleDateRangeProc]
@StartDate datetime,
@EndDate datetime
AS
select * from YourTable t (nolock)
where t.DateField >= @StartDate
and t.DateField <= @EndDate
If @@Error <> 0
Return -1
Return 0
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
STL is a religeon. Enquiries to Reverend Christian Graus
|
|
|
|
|
SELECT Country_Ext_Code FROM Countries_Extensions WHERE (NOT (Country_Ext_Code IN (SELECT country_ext_code FROM rates_phone_zones WHERE Rate_Group_Phone_Code = ?))) doesn't works.
SELECT Country_Ext_Code FROM Countries_Extensions WHERE (NOT (Country_Ext_Code IN (SELECT country_ext_code FROM rates_phone_zones WHERE Rate_Group_Phone_Code = 1))) works fine.
* Note the change "?" x "1"
|
|
|
|
|
What on earth are you trying to achieve with
WHERE Rate_Group_Phone_Code = ?
STL is a religeon. Enquiries to Reverend Christian Graus
|
|
|
|
|
To answer this, we'll need to know what you want to do. SQL doesn't know what you want to do either.
|
|
|
|
|
? is the parameter.
Generally, if you try the sql sentence with the ? in the SQL Query Analizer, the parameter windows should be appears waiting input a value (ej. 1), but with the descripted query (with ?), SQL generate an error; with 1 value works fine. See TABLES DEFINITION
If you try "SELECT country_ext_code FROM rates_phone_zones WHERE Rate_Group_Phone_Code = ?) " this works fine in the query analizer.
The question is -Can be used the IN (SELECT ... clause with a parameter ?-
With the ? the SQL engine say: Syntax error or access violation
Invalid descriptor index
TABLES DEFINITION
TABLE Countries_Extensions
country_ext_code(PK) country_name
1 USA
297 ARUBA
54 ARGENTINA
TABLE Rates_Phone_Zones
country_ext_code(FK) Rate_Group_Phone_Code
1 1
297 1
The query should be show:
Countries_Extensions.country_ext_code
54
in this case the ? is the Rate_Group_Phone_Code value from a user input (ej. Rate_Group_Phone_Code 1).
I need to show all the countries extensions codes(really just the countries names) that does´t exists in the Rates_Phone_Zones.
|
|
|
|
|
Hi,
I have some problem with this query i execute under visual C++6.0
"SELECT Nom, CodePostal, Sum(Montant) AS MontantRemb, DateTraitement <br />
FROM TClient GROUP BY Nom, CodePostal, Montant,DateTraitement <br />
HAVING (((DateTraitement)=#09/05/2002#));"
In Microsoft Access interface it work well but if i execute it via ODBC like this :
retcode = SQLExecDirect(m_hstmt,(SQLCHAR*)strSQL, SQL_NTS);
this isntruction work also but i have a problem with SQL Fetch:
while (( retcode = SQLFetch(m_hstmt))!= SQL_NO_DATA)<br />
{ <br />
SQLGetData(m_hstmt, 1, SQL_C_CHAR, szNomClient, 25, &cbName);<br />
SQLGetData(m_hstmt, 2, SQL_C_CHAR, szCodePostal, 6, &cbName);<br />
SQLGetData(m_hstmt, 3, SQL_C_CHAR, szMontant, 16, &cbName);<br />
SQLGetData(m_hstmt, 4, SQL_C_CHAR, szDateTraitement, 11, &cbName);<br />
} Here retcode return 100 and i can't obtain my data
Thanks in advance for any help
|
|
|
|
|
I am working on a large-scale enterprise application that needs to output a large amount of data in a short time. An older version of the program used DAO, and now, after rewriting in .NET it uses either the Jet OleDb or Sql .NET providers. While the .NET version is significantly faster in performing the calculations of the data that needs to be output, it is excessively slower in outputing it...
I created a console app to perform an empirical comparison. For each data access technology I output 8760 records with each record containg one Date field and 40 Single fields... For the .NET providers I create an INSERT command and execute it 8760 times (repopulating with random values). For the DAO (using an auto-generated interop assembly) I open a recordset on the table and for each record I call Recordset.AddNew, set the values, and then call Recordset.Update...
The results:
Jet DAO - 7 seconds
Sql .Net Provider - 37 seconds
Jet OleDb .Net Provider - 57 seconds
Are the .Net providers not written with massive outputing of data in mind? Does anyone know if someone has written a wrapper around DAO that lets it fit into the System.Data class heirarchy (I'd be very interested in that)? Is there a better way to output a large number of records in .NET (I've tried using DataAdapters which made no difference)?
This matters a lot for me since the new application takes around 4-5 times as long to calculate and output its results (which really matters since this equates to about 8-9 hours per run of the application)..
|
|
|
|
|
I would really like to see all the code (possibly a small article) to see exactly what you are doing. Have you read Nish and Rama's co-article yet with a slew comparison on different Microsoft languages? If not I would highly recommend reading it.
A statistical analysis of the performance variations of assorted managed and unmanaged languages [^]
Nick Parker
If the automobile had followed the same development as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year killing everyone inside.
-Robert Cringely
|
|
|
|
|
He is all of the code... It assumes that there exists an Access db at c:\test.mdb and a SQL db called testSQL on an instance at COMPUTER\SQLServer... The dbs each contain one table named Test, defined by one Date field (Observation) and 40 Single fields (Val1, Val2, ...). The project has a reference to DAO 3.6 Object Library...
Imports System.Data.OleDb
Imports System.Data.SqlClient
Module Module1
Sub Main()
Randomize(-1000)
Dim start As Date = Date.Now
ExecuteDAO()
System.Console.WriteLine("DAO output took " & DateDiff(DateInterval.Second, start, Date.Now) & " seconds.")
start = Date.Now
ExecuteOleDb()
System.Console.WriteLine("OleDb output took " & DateDiff(DateInterval.Second, start, Date.Now) & " seconds.")
start = Date.Now
ExecuteSql()
System.Console.WriteLine("Sql output took " & DateDiff(DateInterval.Second, start, Date.Now) & " seconds.")
System.Console.WriteLine("Press any key to continue...")
System.Console.Read()
End Sub
Public Function ExecuteOleDb()
Dim conn As OleDbConnection
Dim cmd As IDbCommand
Dim i, j As Integer
conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source='c:\test.mdb'")
conn.Open()
cmd = CreateCommand(conn)
For i = 1 To 8760
cmd.Parameters(0).Value = New Date(2002, 1, 1).AddHours(i - 1)
For j = 1 To 40
cmd.Parameters(j).Value = Rnd()
Next
cmd.ExecuteNonQuery()
Next
conn.Close()
End Function
Public Function ExecuteSql()
Dim conn As SqlConnection
Dim cmd As IDbCommand
Dim i, j As Integer
conn = New SqlConnection("Data Source=COMPUTER\SQLServer; Database=testSQL; Integrated Security=SSPI")
conn.Open()
cmd = CreateCommand(conn)
For i = 1 To 8760
cmd.Parameters(0).Value = New Date(2002, 1, 1).AddHours(i - 1)
For j = 1 To 40
cmd.Parameters(j).Value = Rnd()
Next
cmd.ExecuteNonQuery()
Next
conn.Close()
End Function
Public Function ExecuteDAO()
Dim dbEng As DAO.DBEngineClass = New DAO.DBEngineClass()
Dim wk As DAO.Workspace = dbEng.Workspaces(0)
Dim db As DAO.Database = wk.OpenDatabase("C:\test.mdb")
Dim rs As DAO.Recordset = db.OpenRecordset("Test")
Dim i, j As Integer
For i = 1 To 8760
rs.AddNew()
rs.Fields(0).Value = New Date(2002, 1, 1).AddHours(i - 1)
For j = 1 To 40
rs.Fields(j).Value = Rnd()
Next
rs.Update()
Next
rs.Close()
db.Close()
End Function
Public Function CreateCommand(ByVal conn As IDbConnection) As IDbCommand
Dim cmd As IDbCommand = conn.CreateCommand()
Dim param As IDbDataParameter
param = cmd.CreateParameter()
param.ParameterName = "@obs"
param.DbType = DbType.DateTime
cmd.Parameters.Add(param)
Dim cmdText As String = "INSERT INTO Test (Observation"
Dim cmdTextParams As String = "@obs"
Dim scen As Integer
For scen = 1 To 40
param = cmd.CreateParameter()
param.ParameterName = "@val" & scen
param.DbType = DbType.Double
cmd.Parameters.Add(param)
cmdText &= ", Val" & scen
cmdTextParams &= ", @val" & scen
Next
cmdText &= ") VALUES (" & cmdTextParams & ")"
cmd.CommandText = cmdText
cmd.Prepare()
Return cmd
End Function
End Module
|
|
|
|
|
I am using InstallShield Developer 7.04 in order to distribute my application. My application is a maintenance application based on MSAccess. Now I want to delete some rows and add some others in one table. Can that be done using InstallShield and if yes how?
Thanks,
Spiros Prantalos
|
|
|
|
|
I don't know if you can call ADO from Installshield script, but you could certainly create a COM object to do your maintenence and then call that from InstallShield.
Dave.
|
|
|
|
|
Ok. That is great!! Assuming that I create a com object to update my database do I have to create a spcial script function in installscript that will call this component?
Thank you very much. Now I can a light at the end of the tunnel
Spiros Prantalos
|
|
|
|
|
If you're using ISD 7 (Basic MSI Project, as opposed to Standard Project) then why don't you create a custom action that runs an MSI DLL - that can do pretty much anything.
You just need a DLL that exports a function in the format
__declspec(dllexport) UINT APIENTRY MyFunction(MSIHANDLE hMSI) Inside that you can call anything you could normally call from C++, including the Windows Installer API (if you need to pass any properties in).
Paul
|
|
|
|
|
Are there any classes or libraries in C# help me to list all available OLE DB providers in my system?
Are there any requirements to do this work?
Thanks for your help.
|
|
|
|
|
Hey everyone,
I have an app which uses an access database for data storage. I access the app using ADO which has all worked fine in the past. Anyway, I just tried to run the app on a WinXP machine but it doesn't work. I can connect to the DB fine but when I do a "SELECT * FROM FILES" I get the following error
CADORecordset Error
Code = 80040e37
Code meaning = IDispatch error #3127
Source = Microsoft OLE DB Provider for ODBC Drivers
Description = [Microsoft][ODBC Microsoft Access Driver]
The Microsoft Jet database engine cannot find the input table or query 'FILES'.
Make sure it exists and that its name is spelled correctly
However, I can open this database from within access OK and I can also get into the FILES table through an ASP page using the same connect string I use in my app.
The WinXP machine is using the latest MDAC (2.7 refresh) and I have updated the JET drivers to sp6.
Anyone have any clues?
Cheers
James
|
|
|
|
|
Does it happen when accessing other tables?
Any chance "FILES" is a keyword in Access?
Cheers,
Simon
"Sign up for a chance to be among the first to experience the wrath of the gods.", Microsoft's home page (24/06/2002)
|
|
|
|
|
Guess, what? It wasn't opening the DB I thought it was. It was opening an earlier version in a different path .
Thanks for the help though.
Cheers
James
|
|
|
|
|
Hi all,
I see that the OLEDBProviderInfos can list all available OLE DB providers. But you must install MS SQL to use Microsoft DTSPackage Object Library.
Are there any other way to do this work?
|
|
|
|
|
I have a problem. A program on a computer issues a query with a date in it to another computer that runs SQL Server. The problem is that the client computer has a different locale than the server computer.
Is there a way to get the SQL server locale from the client so a properly formatted query can be sent.
Tx
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|