|
I found a nice matrix over datatypemappings SQL-server 2000 <> ADO 2.6 at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adosql/adoprg02_294j.asp
Refering to the matrix, varchar should be mapped to adChar, but adVarchar seems more logic to me. Is it an printerror?
|
|
|
|
|
dim str as string
str= "INSERT INTO employees Values(@ID,@FN,@LN)"
dim InsCom as new SqlCommand(str,SqlConnection1)
plz tell me what is the error in this code.
MS Visual Studio.NEt shows error in the following SqlCommand function.
when i write this line dim InsCom as new sqlcommand(str,Sqlconnection1)
then after new the window pops up but there is nothing like sqlcommand in there?
OR
plz tell how to execute a query from a MS-ACCESS database?
thnx
Rashmi
|
|
|
|
|
You need to build your sql string differently. The parameters are inside of your quote marks so the values can not be passed in. Depending on your datatypes it should look something more like:
dim str as string
str= "INSERT INTO employees Values(" + @ID + "," + @FN + "," + @LN + ")"
dim InsCom as new SqlCommand(str,SqlConnection1)
If your datatypes are int you may have to do something like str(@ID) as well as add single quotes if your datatypes are char.
|
|
|
|
|
Is there some master chart somewhere that gives me a map on how to relate data types between VB / C# and SQL server?
I have looked all over google and see tons of posts just like mine with regards to VB6 but no one seemes to answer them.
|
|
|
|
|
Here is part of it:
SQL Server Data Types Corresponding VB Data Type
http://www.tsqlsolutions.com/Articles/Index.cfm?ArticleID=9728
|
|
|
|
|
I'm presuming that you want the .NET to SQL datatype mappings?
Check out the help on MSDN for "System.Data.SqlTypes Namespace".
It shows the mapping between native SQL types and .NET SQLType types.
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)
|
|
|
|
|
How do you perform row locking in Transact-SQL? Do you have an example please?
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
|
|
|
|
|
Check this
http://www.4guysfromrolla.com/webtech/101100-1.shtml[^]
Cheers,
Joao Vaz
A Programming Language is a tool that has profound influence on our thinking habits -The late giant Edsger Dijkstra 1930 - 2002
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary. -
|
|
|
|
|
I have an odd question here for all you data-centric folks...
Let's say that I am developing a webservice that will perform some actions on a SQL database. I am to the point where I am starting to code the data-centric portion of the service. I want to add a connection to my webservice, but find that I can't seem to reference a DSN. It looks to me like I have to reference the servername and database directly.
Alot of this fancy ADO.NET integration into the IDE seems to me to look like they expect us to develop on the same system we are going to deploy on? If I am developing on a system where the servers name is 'Serv01' and use all the fancy IDE integration wizzards to set things up, then move to a deployment where I have no control over my server names, how if my app supposed to function? This is why I like DSNs. I can mandate what they are named, and as long as they reference a server that has the proper database that I need my app does not care.
Am I the only one that sees this as a problem?
|
|
|
|
|
We got around this by storing the database server name and database name in the registry. It is set during the installation of the program on the end computer.
|
|
|
|
|
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!
|
|
|
|