|
What exactly do you mean by password protected?
You can download SQL Server Express for free (4Gb data file limit). It has security - i.e. you need a login to get into the database.
Anyone can pick the MDf (data) file and attach it and use the data.... unless you encrypt the data with or write your own encryption algorithm.
|
|
|
|
|
Thank you very much for reply.
I want to protect my database structure. So nobody can easily open my user database to view my table structure. Minimum there is a password protection to open the user database file.
Which database can do it? MySQL? ACCESS?
Thanks,
|
|
|
|
|
Yes all of those databases allow you to 'password' protect yuor database in some manner, but the DBA on site always knows this password.
|
|
|
|
|
Hi,
I am trying to insert a new record into my table Products. The insert is done via a windows forms application that i am developing using vb.net.
I am having problems trying to insert a new record into the Products table. The SQL code is not functioning properly. The Products table has 2 foreign keys and this is where i am having the problem i think. The table structures are as follows:
Products:
PK_ProductID, ProductName, FK_SupplierID, FK_CategoryID, QtyPerUnit
LK_Categories
PK_CategoryID, CategoryName, Description
LK_Suppliers
PK_SupplierID, SupplierName, Address, PostCode
I have created a query call ProductDetails that is used to add a new product item. The user enters the details of the new product: ProductName, SupplierName, CategoryName, QtyPerUnit and the Products table should then be updated. I have used the CategoryName and SupplierName fields instead of the FK_CategoryID and FK_SupplierID as the ID's are just auto numbers and would bear no identity to the user.
However i am having extreme difficulty in getting an INSERT statement to work.
Please can someone help me?
|
|
|
|
|
Do the category and supplier exist before you try to add the product?
What code are you using to perform the insert?
|
|
|
|
|
yes they do exist. The LK_Suppliers table and the LK_Categories table have the values stored already. Both these tables are lookup tables, where the suppliers and categories details are stored. The products table uses the ID's from the LK_Categories and the LK_Suppliers tables as each product item has a category and supplier.
Currently the INSERT Statement that i am using is as follows:
'"INSERT INTO Products (ProductName, SupplierName, CategoryName, QryPerUnity)
VALUES('" & Trim(txtProdNameIns.Text) & "', '" & Trim(SupplierNameComboBox.Text) & "' , '" & Trim
(CategoryNameComboBox.Text) & "' ,'" & Trim(txtQPUIns.Text) & "')"
However when i run this code in my application the following error comes up:
"The INSERT INTO Statement contains the following unknown field name: 'SupplierName'. Make sure you have typed the name correctly, and try the operation again."
Any advise with examples would be most appreciated.
Thanks
|
|
|
|
|
It sounds like Products does not have a column called SupplierName. I suspect it is actually SupplierID if its a FK to the Supplier table.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Yes that is true. I have created a query that displays the category name and supplier name, i did this because the FK_CategoryName and FK_SupplierName in the Products table are auto numbers and would not mean anything to the customer. I have linked the Products table, LK_Categories, LK_Suppliers with the ID's however i want to display the category names and supplier names to the user.
Then when the user wants to add a product item i want it to insert a line in the Products table, but where i am going wrong is that the FK_CategoryID and FK_SupplierID are foreign keys in the Products table are that is not referenced in my SQL INSERT statement.
I hope you understand my point.
I am desperate to get this working, please help.
|
|
|
|
|
Before you insert the product you need to translate the category and supplier to get their IDs.
|
|
|
|
|
What you have done to display the nformation is correct, but what you need to do id translate the supplier and category names back to their ID values to insert into the product table. YOU have to do the lookup and supply the correct values for the insert.
Personally I would be doing the insert in a stored procedure and would look up any FK values in the stored proc.
Hopefully this makes sense
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
hi i was just wondering which is the better way to insert data into database when i got large amount of data to add in.
way 1
do
"insert into db1 () values()"
execute command
while()
or
way 2
do
string = string + "insert into db1 () values()"
while()
execute command
also if lets say way 2 somewhere in the middle of the insert command there is an error would the code before it still be added?
|
|
|
|
|
The first is better, but neither is as good as:
cmd.CommandText = "INSERT INTO table ( ... ) VALUES ( @Param0 ... )" ;
(create and add parameters to cmd)
while ( ... )
{
(set parameter values)
cmd.ExecuteNonQuery() ;
}
And use a transaction if you need to.
|
|
|
|
|
"in the middle of the insert command there is an error would the code before it still be added?"
You can use sqlTransaction , and can rollback and commit transactions as well as can make commit points
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
Best way to see which is performing fast is to profile the application. I will go with the first method with the modifications what PIEBALDconsult suggested.
Second method would be good in performance but it is hard to troubleshoot when you get error in one of the inserts.
neodeaths wrote: also if lets say way 2 somewhere in the middle of the insert command there is an error would the code before it still be added?
Quote Selected Text
It will be added. If you want to ensure all the data gets added, run the queries in a transaction.
|
|
|
|
|
This is not a question, but feel free to reply if you have any opinion about the subject.
I have often seen the subject of this message as a question, here on CP, and having just found this article/blog (link below), I thought that I would post it here in case it is of use to someone.
If you follow the link, take the time to read the comments at the bottom as some of the views differ from those of the author.
Here it is.[^]
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
In my opinion both Pinal Dave (well i really appreciates his efforts He is not doubt a SQL Guru ) and on the other hand users are right on their respective end.
i will also use Sql server if i am in Microsoft env. and tools while will def. go for mysql in case of php and linux/unix platform
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
softdev_sup wrote: i will also use Sql server if i am in Microsoft env. and tools while will def. go for mysql in case of php and linux/unix platform
I think that that is the right way to think about it too.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Does anyone know how I can create a report on reporting services that selects information from two databases on the same sql server?
Any help would be grateful
Michael
|
|
|
|
|
|
|
Aw, my aplogies, there's no need to create a linked server. You can just prefix the entities that you need to denote the database;
SELECT *
FROM [database].[schema].[table] E.g.;
SELECT *
FROM Northwind.dbo.Employees
I are Troll
|
|
|
|
|
|
hi
i have table that i want to change any field type (from int - to - varchar)
i get this error:
saving changes is not permitted........
|
|
|
|
|
Probably you get this error while you alter your table in design mode.. If so then you need to change setting form option... set allow auto generate sql script true.. If this issue still not resolve then please let me know...
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
Thanks
Md. Marufuzzaman
|
|
|
|
|
thank's for the help
yes, i work in design mode.
but, where i can find this ...option... set allow auto generate sql script true ?
|
|
|
|