|
yesh, I understand that part, but then all the fancy wizzard stuff goes to hell.
If it let you point to a DSN it could all be happy.
|
|
|
|
|
To point to a DSN, you need to download OBDC.NET from Microsoft's site
ODBC .NET Data Provider[^]
and instead of using System.Data.OleDb... objects, you use Microsoft.Data.Odbc... objects.
Remember that ODBC is a Windows thing but .NET is supposed to be as neutral as possible.
Paul
|
|
|
|
|
Well according to the download page this comes as part of Mdac 2.7, which is installed as part of .NET, so I should already have this.
I'll take a look at it when I get back to the home office.
|
|
|
|
|
Ray Cassick wrote:
Well according to the download page this comes as part of Mdac 2.7
No, it says it requires MDAC 2.7
Trust me, I've been using it for a while. It lacks some of the wizards that OleDb uses, but that's only a good thing in my opinion.
Paul
|
|
|
|
|
Well I'll give it a try then...
Thanks.
|
|
|
|
|
How to store pics or photo at SQL 2000 server database?
I Love C++
|
|
|
|
|
I always write a little program for myself to do it.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Not sure what language you are going to be using, however the datatype is a BLOB, here is an example on how to do this with the .NET Framework in C#.
public void StorePicture( string filename )
{
FileStream fs = new FileStream( filename, FileMode.Open, FileAccess.Read );
byte[] imageData = new Byte[fs.Length];
fs.Read( imageData, 0, (int)fs.Length );
fs.Close();
SqlConnection conn = new SqlConnection("");
SqlCommand cmd = new SqlCommand("StorePicture", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@filename", filename );
cmd.Parameters["@filename"].Direction = ParameterDirection.Input;
cmd.Parameters.Add("@blobdata", SqlDbType.Image);
cmd.Parameters["@blobdata"].Direction = ParameterDirection.Input;
cmd.Parameters["@blobdata"].Value = imageData;
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch
{
throw;
}
finally
{
conn.Close();
}
}
HTH
Nick Parker
|
|
|
|
|
When designing a database frontend, is it customary to write a class for the actual data being saved?
Say the user inputs data to a form. The form places the data in an object then passes the object to a function to write to the database. If a class was written, you could do things like overload the assignment operator.
On the otherhand if you supported dynamic creation of new fields, the class that was developed would be rendered useless.
I am inclined to write a class to encapsulate the data, but would like input from experienced database programmers.
Thanks all
|
|
|
|
|
Paul Silvernail wrote:
When designing a database frontend, is it customary to write a class for the actual data being saved?
Yes, it is useful to have a wrapper class that encapsulate database record management (it usually implements so called CRUD-functions: Create/Read/Update/Delete). Dynamic creation of new fields is typically needed during development phase, so it is not supported by wrapper classes.
Vagif Abilov
MCP (Visual C++)
Oslo, Norway
If you're in a war, instead of throwing a hand grenade at the enemy, throw one of those small pumpkins. Maybe it'll make everyone think how stupid war is, and while they are thinking, you can throw a real grenade at them.
Jack Handey, Deep Thoughts
|
|
|
|
|
Hello!
How is it possible to list all objects(tables, views) in a database that have been created by the databases designer and NOT by SQL server?
I know that
EXECUTE sp_databases @table_type="'TABLE'"
shoudn't list any system tables. But if I execute this statement on a database I created, I always get tables I didn't create and which the Server Explorer of VS doesn't show? So how can I get a list of only the tables (it's the same for the views) that I created??
Cheers
TIA
Martin
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|
|
exec sp_tables NULL,dbo,dbname,"'TABLE'"
exec sp_tables NULL,dbo,dbname,"'VIEW'"
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Unfortunately that's exactly the same as
exec sp_tables @table_type="'TABLE'"
I get my user tables and a table called dtproperties... But Server Explorer can sort it out
But thanks anyway
Cheers
Martin
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|
|
Martin Häsemeyer wrote:
How is it possible to list all objects(tables, views) in a database that have been created by the databases designer and NOT by SQL server?
to list all user tables
select * from sysobjects where type='U'
to list all views (may not all be user though)
select * from sysobjects where type='V'
Soliant | email
"The whole of science is nothing more than a refinement of everyday thinking." -Albert E.
|
|
|
|
|
This method seems to produce exactly the same results but with additional information...
Maybe I'll have to manually exclude the additional sysobjects and hope that their names are always the same.
Cheers
and thanks for the reply
Martin
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|
|
Try selecting it from the INFORMATION_SCHEMA views directly.
SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME <> 'dtproperties' AND
TABLE_TYPE = 'BASE TABLE'
ORDER BY 1
|
|
|
|
|
Try this (I'm not at a SQL box at the moment so it might not work 100%)
<br />
SELECT *<br />
FROM INFORMATION_SCHEMA.TABLES<br />
WHERE <br />
OBJECTPROPERTY(OBJECT_ID(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)), 'IsMSShipped') = 0<br />
AND TABLE_TYPE = 'BASE TABLE'<br />
|
|
|
|
|
Hi all I am hoping someone here can help me.
I am sufferering from the problem detailed in http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q325681[^]. However when I try to resolve it by using the first resolution I keep getting a failure with the message
'Failed to copy objects from Microsoft SQL Server to Microsoft SQL Server'
and when I click on the error
'[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name dbo.Locations'
now Locations is a view - how can it be invalid? It works when I run it.
Strange thing is even if I delete the view - it still complains about the same thing - now that is confusing. Please help.
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
Can you explain what you are trying to do? Maybe the view is based on tables that do not exist in the location you are trying to create the view in.
|
|
|
|
|
I am trying to export a database from X -> Y where Y has a collation set to 'server default' and had only just been created. I have tried it where the collation was the same - alas same error.
I need to move the collation to be ther server default so that I can use it properly within Visual Studio.Net .
Maybe I'll have to try move my database from X -> Y in another fashion and then copy the data - via scripts perhaps - how would I do that?
Or maybe try moving the database a piece at a time eg tables then views then SPs - what do you think?
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
Yes, I would just do it a bit at a time. Since you are having problems with the views do the tables and data first. Once they are there it is easy enough just to go back and script the views and procedures.
Also see:
http://www.microsoft.com/sql/techinfo/tips/administration/changingcodepage.asp
|
|
|
|
|
Thanks - I'll give it a go.
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
eventually finshed it - 6 hours later - thank god the database wasn't any bigger.
I was the only developer (and the new boy) who really wanted to use VS.NET to see what was going on rather than keep switching between Enterprise Manager, Query Analyzer and Visual Studio. So it was down to me to do the update.
I followed the steps in the KB article - but it never worked cleanly so....
steps to export + problems I found at each stage
i) tables + defaults + rules + datatypes
P1) When exporting tables any Foreign Keys that constrain on the same table (I hope you understand what I mean) failed - so I had to remove them for the export and then re-establish them after
ii) views
P2) Some of the views didn't work on the original database so I had to fix them first - I really hate some people.
P3) Some of the views failed due to the collation still being different and on the old collation. I had to walk though every table and change any collation to 'server default'. Eventually I got the last few views to go through.
iii) stored procedure + functions
iv) copied the diagrams over by messing with the dtproperties table
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
How?
This is my first real venture into SQL (other than SELECT * from XYZ) and I am having trouble with a stored procedure - all the data in looks okay but... it doesn't return the right answer. Is there a way to debug a SP so that when called I can see what is going on.
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
The method I use to debug a procedure is to put print statements throughout the procedure so you can see what the values you are getting really are. It's a clunky method but usually works well. Most procedures are not that complicated. You have to do this in Query Analyzer.
If you have specific statements you are having problems with paste them here.
|
|
|
|