|
Here is my situation...
I have to develop tables for a specific product. Currently I have a "Product" table which has the "ModelId", "Features", etc. There is also a table I have called "ProductDetails" which some special performance data.
The problem is, this product can be "Mounted" in three different configurations. The product information for each of the three different mounts are identical but they have a different "ProductId".
What is the best way to design this?
Thanks
Mark Sanders
sanderssolutions.com
|
|
|
|
|
Why not have a Configuration table that specifies the attributes for the configuration. Then put a Configuration ID in the Product or ProductDetails table, which ever one makes more sense to you, to link the configuration to the productId.
Jeremy Oldham
|
|
|
|
|
Hi all
I have a problem with reading arabic data from an Access 2000 DB File in asp 3.0
the problem takes two forms:
1) when I add some Arabic data to the access file and upload it to the server,,I get some rubish when I read the data using ASP 3.0 on the server .. while I can read it when using localhost.
2)When I add data in arabic to the database using an ASP form I can read it again using ASP and works fine .. but when I downlaod the file and open it in Access or asp in localhost I see some rubish again..
Is it a problem of collations , locales etc .. ?
please me help finding a solution..And send your questions if you find my post unclear..
|
|
|
|
|
It goes well when I set Session.Codepage to an appropriate value.
Session.CodePage = 1256
|
|
|
|
|
is there a way to install a msde database using an instance name that doesnt put the computer name in front of it? basically if you dont put an instance name in the setup ini file then the name of the instance will be your computer name. so i gave it one and now instead of the instance being say Developer1 its is now Developer1\Sql1 i have even tried completely uninstalling sql and installing only the msde but to no avail anyone have any ideas?
|
|
|
|
|
With the latest SqlServer (sp3), If no instance name is specified, the default instance name MSSQLSERVER is used.
However, the location will always be MyComputersName\MySqlServerName. This enables you to access the server across a network and is standard format for network connections like mapping drives etc.
Why is this a problem?
Regards
Wayne Phipps
Time is the greatest teacher... unfortunately, it kills all of its students
|
|
|
|
|
Greetings,
I run this code code on a sql 2000 server full version "CREATE DATABASE MYTEST_DB", and it creates my
database fine.
But when I run the code on a desktop version of it I get an error message of "DB_E_ERRORSINCOMMAND"!
Anyone have any ideas as to what I am doing wrong? I was under the impression that what I develop under
a full version should work under the desktop version, was this wrong?
Thanks in advance.
|
|
|
|
|
For some reason the desktop version required me to issue "USE MASTER" first before I did the create whereas the full version didn't do this. After I added that the call worked.
|
|
|
|
|
I am having problems fetching text column from sybase db table.
I have used getbytes, getchars & getstring with oledb.datareader.
I have also used dataset with oledb.dataadpater. Nouse.
Anyone who has used oledb, ado.net to fetch text columns. Is it working for you. If so can you give me any insight on how you got it wotking, what version of oledb are u using.
Thanks!!
Vinay
|
|
|
|
|
I was looking for a SQL query that will allow me to take a 9 digit numeric value in a varchar field and format it in a standard social security format, ie: ###-##-####. So basically I'd like to update all of the migrated records, some of which have the dashes already, some of which don't, and standardize the format. I could of course do a select * from the table, and write a program to do this one row at a time, but I would rather do this globally with a query if possible.
Thanks,
Steven.
|
|
|
|
|
I'm trying to use a Recordset for returning custom data to the client. The data does not come from the database, it is created on the fly from various data.
ADO does support this kind of Recordsets, but all samples I've found are in VB, and the C++ samples just detach the Recordset from the source.
I just create a new Recordset object, add the columns to the Fields collection with Append(...).
I am stuck at the Open() call which requires a connection, but that is exactly what I dont have.
Help? Please?
Off to Brazil in a few days
|
|
|
|
|
Ok, if anyone ever wants to know:
use
Open(vtMissing, vtMissing, adOpenUnspecified, adLockUnspecified, adCmdUnspecified);
Off to Brazil in a few days
|
|
|
|
|
Hello all,
What are the date functions in VBA? I have a string, and I'd like it to hold today's date. What do I call to get the date?
Dim theDate as string
theDate = date()
I know that is wrong, but what do I do?
Thanks
Nick
|
|
|
|
|
I'm not too sure about vba:
In VB it's:
Dim strDate as String
strDate = Format("dd-mmm-yyyy", Now()) ' replace with your own format
|
|
|
|
|
I have a query regarding how to backup and restore single database tables in MS SQL Server through Visual C++ programming code. Is it possible to do so? I have read in MSDN about backing up single database files but i have no clear concept about database files. Are they referring to tables by files?
|
|
|
|
|
I don't recall there beeing any functionality in SQL server to backup a single table without planning for it first. It has to be planned for by creating filegroups and files.
- A filegroup is a collection of one or more files.
- A file is a file in the filesystem.
- On SQL Server you can control wich filegroup(s) a table is stored in.
- SQL Server allows you to control what file(s) or filegroup(s) to backup.
The prosess goes something like this:
1. Create a database filegroup containing one file in your database.
ALTER DATABASE MyDatabase<br />
ADD FILE TO FILEGROUP MyOtherFilegroup<br />
(<br />
NAME = MyOtherFile,<br />
FILENAME = 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\mydb_otherfile.ndf',<br />
SIZE = 5MB,<br />
MAXSIZE = 100MB,<br />
FILEGROWTH = 5MB<br />
)
2. Create (or move) the table on that database file.
CREATE TABLE Tablename(<your table definition here>) ON MyOtherFilegroup
or (to move a table from one filegroup to another) have a quick look in SQL Server Books Online. Select the index and lookup "filegroups, switching filegroup for table".
3. Take a backup of that specific file or filgroup.
The backup command will look something like either
BACKUP DATABASE MyDatabase FILE = 'MyOtherFile' TO 'MyBackupDevice'
or
BACKUP DATABASE MyDatabase FILEGROUP = 'MyOtherFilegroup' TO 'MyBackupDevice'
|
|
|
|
|
You could also use the BCP (Bulk Copy Program) utility along with an script to create or alter the table. (Automatically made for you with Visual Studio .NET).
John
|
|
|
|
|
Hello all,
I have what I hope is a quick question. In my Access 2000 database I have a Table called Candidates. In this table there is a Field called LName. How can I get the data in this field without opening the table?
This what I am trying to do. In the Main Form of my database, you can eneter a Last Name and hit the Command button and it will open the Candidate Table to the first occurence of the person with that last name. I'd like to write an autofill ability in the Main Form. This way when I type A into the space where you type in the last name, it will automatically fill the text to Aardvark for instance. And then if I hit another letter, like b and the string in there is "ab" it would return the first last name with Ab, for instance Aba.
Now, I know the logic behind how to do what I want, but I need the syntax.
How can I make a string equal the text in the last name field?
Would it be:
Dim lastName as String
lastName = [Candidate].[LName] ??
Any help you can offer me would be great.
And one more quick question.
Is there a way to access the characters in a string?
Can I type lastName[1] and get the first letter of the string?
Again thank you very much.
Nick
|
|
|
|
|
Open the table, read the last names into a listbox, then close the table. Not certain, but after you've done that I believe you can use the properties of a listbox to set it to autofill. If not, you can probably find example code for creating an autofill listbox.
>>>-----> MikeO
|
|
|
|
|
There are 4 fields in my database table. First fields is an integer, second is a string, third is a date field, and the fourth is a currency field.
I am using a combo box to select the field to be search, a text box for the value of the field to be searched, and a command button once clicked will invoke the filter.
Items in the combo includes the 4 fields names and another item "<everything>" which will disable the textbox for the filter value but once the command button is clicked, the recordset will be refreshed and set filter to nothing.
How to implement it. Please show example statements to filter using each of the above 4 fields. Also please include how to set the filter to nothing.
Thanks in advance
|
|
|
|
|
Hi. I'm trying to use ExecuteReader method in my code I'm getting an error. Could you please tell me what am I doing wrong? Here's the code:
SqlConnection tmpconn = new SqlConnection(this.connString);
tmpconn.Open();
string tmpsql = "select id from tbldeneme where username='a'";
SqlCommand tmpcmd = new SqlCommand(tmpsql,tmpconn);
Response.Write(tmpcmd.ExecuteScalar().ToString()); //<-- error line
Here's the error:
System.NullReferenceException: Object reference not set to an instance of an object.
|
|
|
|
|
kensai wrote:
Response.Write(tmpcmd.ExecuteScalar().ToString()); //<-- error line
You are getting a NULL returned from the database.
To be "safe" about using ExecuteScalar, assign it to a variable first, then put it out as string. Assuming your id field is integer...
//will return 0 if null record
int i = Convert.ToInt32(tmpcmd.ExecuteScalar());
if (i > 0)
Response.Write(i.ToString());
else
Response.Write("Record not found");
|
|
|
|
|
I need a perl script that I can run as a cron job.. The script needs to connect to an ftp server and grab a csv file and create a MySQL table from that file. I then need to know if its any different for a .txt file.
Any help is appreciated
|
|
|
|
|
This will be a long post but any insight will be greatly appreciated.
Process Description:
I have to write a C# method which will take as its parameter a System.Data.DataTable and then write this DataTable to a new dBASE IV table on disk.
Current Solution: (not a good one)
Here is my current solution in C# which is very very very slow (It takes 5+ minutes to output a 10MB .DBF on a dual 2.4 Zeon machine with 2GB of RAM running a RAID 5).
public void WriteTable(DataTable table)
{
string columnString="";
foreach(DataColumn column in table.Columns)
{
string type = "";
switch(column.DataType.ToString())
{
case "System.String":
type = "varchar(" + MaxLength(column) + ")";
break;
case "System.Int32":
type = "int";
break;
case "System.Double":
type = "double";
break;
default:
throw new ArgumentException("Data type not found.", column.DataType.ToString());
}
columnString += column.ColumnName + " " + type + ", ";
}
columnString = columnString.Substring(0, columnString.Length-2);
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + directory + ";Extended Properties=dBase IV";
sqlString = "CREATE TABLE " + name + " (" + columnString + ")";
connection = new OleDbConnection(connectionString);
command = new OleDbCommand(sqlString, connection);
command.Connection.Open();
command.ExecuteNonQuery();
command.Connection.Close();
command.Connection.Open();
int columnCount = table.Columns.Count;
foreach(DataRow row in table.Rows)
{
string valueString="";
for(int i=0; i < columnCount; i++)
{
switch(row[i].GetType().ToString())
{
case "System.String":
valueString += "'" + ((string)row[i]).Replace("'", "''") + "', ";
break;
case "System.Int32":
valueString += System.Convert.ToString((int)row[i]) + ", ";
break;
case "System.Double":
valueString += System.Convert.ToString((double)row[i]) + ", ";
break;
case "System.DBNull":
valueString += "'', ";
break;
default:
throw new ArgumentException("Data type not found.", row[i].GetType().ToString());
}
}
valueString = valueString.Substring(0, valueString.Length-2);
sqlString = "INSERT INTO " + name + " VALUES (" + valueString + ")";
command.CommandText = sqlString;
command.ExecuteNonQuery();
}
command.Connection.Close();
}
Questions:
- Any suggestions on a much better way to do this?
- Do you think it would be possible/better to try and see if I could use an OleDbDataSet/OleDbDataAdapter solution?
- Can anyone give me some insight as to why this solution is incredibly slow other than the fact that there is a very large amount of records to write out?
Any comments, suggestions, samples, etc. will be greatly appreciated.
Thanks
Mark Sanders
|
|
|
|
|
Mark Sanders wrote:
Do you think it would be possible/better to try and see if I could use an OleDbDataSet/OleDbDataAdapter solution?
No, probably this will be slower.
Mark Sanders wrote:
Can anyone give me some insight as to why this solution is incredibly slow other than the fact that there is a very large amount of records to write out?
Use parametrized queries: this will give you a huge performance boost. See the OleDbParameter class for examples.
Notice that using parametrized queries you won't need anymore to replace "dangerous" chars like the quotes.
This probably will eliminate the need for the switch on the type and all the string conversions, too.
For another tip, do not make massive string concatenations using the String class. This is slow, and will kill the performance of the garbage collector. Actually, this can lead to hard-to-find performance problems. Use the System.Text.StringBuilder instead.
My latest article: GBVB - Converting VB.NET code to C#
|
|
|
|