|
Pardon me if i'm missunderstood,
but those two queries is tend to insert different value to the table, so what is the reason you should merge them into one query??
maybe you could execute only one query by your application code , such as
if xxx = "true" then
strQuery = "INSERT INTO criminal(cr_name,no_times,cr_desc,cr_pic,fing_print)VALUES('" + textBox1.Text + "','" + textBox5.Text + "','" + textBox4.Text + "','" + textBox6.Text + "','" + textBox7.Text + "')";
else
strQuery = "INSERT INTO criminal(pic_name) SELECT substring(cr_pic,11,30) FROM criminal";
end if
|
|
|
|
|
i cant apply if because i want to insert one record which includes the columns in both queries, actually i want some solution to insert cr_name,no_times,cr_desc,cr_pic,fing_print,pic_name
using one query not two separate SQL quries
i want one row to be inserted
|
|
|
|
|
1 - try reading the post on how to ask questions
2 - try using parameterised queries, so you're not open to injecton attacks
3 - try using real variable names, so your code is readable
What was the question ?
The most logical way I can see to do this, is to drop a column which always contains a substring of a value in another column, that's just duplicaton of data. Work out the pic name from the path in code, or write a proc that returns it as seperate data, but based entirely on the one column that contains all the data you need.
OR, a yucky way to do it that would at least work, would be to store the Id of the column in question, and then update ony that, instead of doing an insert, which is obviously not what you want.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
STRQRY="INSERT INTO criminal
SELECT '" + textBox1.Text + "','" + textBox5.Text + "','" + textBox4.Text + "','" + textBox6.Text + "','" + textBox7.Text + "'
substring(cr_pic,11,30) FROM criminal
"
|
|
|
|
|
Other people have already answered the questions for you but I feel the need to weigh in on your architecture a little bit.
1. You really shouldn't rely on the default names that you get in Visual Studio. Consider renaming textBox1, et al, to more meaningful names.
2. Don't create direct SQL strings like this. This is bad bad practice which should be avoided at all costs because you have opened your code up to SQL Injection attacks. See this[^] article for more information.
3. Consider moving your data access logic into a separate data access layer (DAL).
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi all, this is my first post here.
I want to know if there is any chance to create a report using SQL 2005 Report Service to mimic the Data-Auto Filter tool in Ms Excel. In this case, i want to create in matrix report.Let's say I have a dataset using this query :
select p.Proj_ID, p.Division_ID, p.Division_Desc, p.Department_ID,
p.Department_Desc, p.Type
from project p
left join Mill m on p.mill = m.org_area
I have create a matric report, with
P.Type in Row Area,
Division_Desc in Column area and below Division_Desc I have group base on Departemen_Desc.
Proj_ID in Data Area.
I want to create something like combo box in the report column header to choose witch Division to shown.
Is there any possible way to create such thing?
Thanx for any information.
|
|
|
|
|
i want to read XML file from sql server 2005. Is there any stored procedure that can read xml file data and store the values in table?
|
|
|
|
|
I have datas from base sql 2000
example
what I get from base
id b1 b2 b3 b4 b5
1 10 11 21 35 39
2 03 18 33 39 45
3 14 17 25 31 44
what I need through VBcode
1 0 1 1 5 9
2 3 8 3 9 5
3 4 7 5 1 4
how do I get this
thanks
jaakinye
|
|
|
|
|
|
I am having trouble with 3 delete queries in my c# application(Win Mobile database)and MSVS 2005, two other Delete queries run fine. All the Delete queries run fine on Win XP, just not in Vista(Vista's User Account Control off). Here is the simple query
DELETE FROM [tableName] I get error SQL Execution error 3640. I get this error whether I am debugging in msvs2005, or running in the Query Designer or if I just run the application outside of msvs2005.
I posted this in C# but someone mentioned that it might be better posted here.
I can get a Delete Query to work if i use the key columns like
DELETE FROM Horse
WHERE (CODE = @p1) AND (Stable = @p2) AND (HorseName = @p3)
this one is not really useful to me though since I am trying to delete all rows no matter the value in these columns.
Hope someone has an idea.
If not is there any other way I can delete all rows from a data table?
I didn't quite understand how to use TRUNCAT TABLE in the Query Designer in MSVS 2005.
If anyone will accept the database tables to see if they get teh same error I will be happy to send them to you.
Thank you
Jon Stroh
Thank You
Jon Stroh
|
|
|
|
|
THERE IS PHP PROJECT IN WHICH A SMALL CHANGE IS RQUIRED for a PHP coding.those who can able to do the coding please contact me in 9884112963or mail me at haarishg@yahoo.co.in asap
-- modified at 14:16 Tuesday 18th September, 2007
|
|
|
|
|
The forums is not the place for this. Post this stuff on the Jobs Board[^].
|
|
|
|
|
Please stop posting stuff like this. Try RentACoder.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
greetings everyody,
When building an application that utilises a databases such as SQL Server or Sybase SQL Anywhere one can use stored procedures to manipulate the database. For example, I use the follwing bit of code in my DataAccess class:
SACommand cmd = new DataAccessor(m_connectionString).GetCommand("[OrderDetails.UpdateInventory]");
cmd.Parameters.Add(new SAParameter("@Quantity",Quantity));
cmd.Parameters.Add(new SAParameter("@ProductID", ProductID));
cmd.Parameters.Add(new SAParameter("@DistributorID", DistributorID));
cmd.Parameters.Add(new SAParameter("@InventoryReceiptHeaderID", ReceiptID));
cmd.Parameters.Add(new SAParameter("@OrderID", OrderID));
cmd.Parameters.Add(new SAParameter("@DeliveryNote", DeliveryNote));
cmd.Parameters.Add(new SAParameter("@UserID", UserID));
cmd.ExecuteNonQuery();
Problem is MS Access does not have stored procedures.
Now, im trying to avoid typing SQL statements directly in my code. Im hoping to use queries in my MS Access databse which i pass parameters to etc
How can i achieve the same in MS Access 2000/2003 database?
|
|
|
|
|
pete007_ke wrote: Now, im trying to avoid typing SQL statements directly in my code. Im hoping to use queries in my MS Access databse which i pass parameters to etc
How can i achieve the same in MS Access 2000/2003 database?
I have never tried this before, but I'm assuming it could work. In your Access database, you could write your "stored procedures" in VBA. Having your functions stored in the database, I'm pretty sure you could call those functions and get their returns.
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
I call a certain stored procedure in a loop (all within another SP), for every loop the procedure is executed to another server, some of the servers are very far away and connected on slow VPN lines, the procedures could execute for as long as 4minutes.
How do I set the time-out period to be longer? Since I suspect it's a time-out which causes the procedure to fail to these servers.
I'm implementing something like this:
CREATE PROCEDURE procDistributeData
AS
DECLARE
@main varchar(50),
@child varchar(50),
DECLARE rst CURSOR LOCAL FOR
SELECT MainServerInstance, ChildServerInstance FROM tblServers
OPEN rst
FETCH NEXT FROM rst INTO @main, @child
WHILE @@fetch_status = 0
BEGIN
EXEC procDistributeToServer @main,@child,@error out
Print @error
FETCH NEXT FROM rst INTO @main, @child
END
CLOSE rst
DEALLOCATE rst
|
|
|
|
|
Would it be possible to rearchitect this slightly? For instance, you may just want to trigger the task to run on the remote server via DTS somehow.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Are you suggesting doing something like a "PULL" of the data from the main server?
Doing it my way means I have central control of the data distribution.
I know how to set a stored procedure's time-out when calling it from, say, VB code, but I don't know how to do it within another stored procedure.
|
|
|
|
|
Without knowing what your architecture/problem is then I can't say. I'm just suggesting that you might be able to use different ways to do this.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Ok, basically I have a main server and many "child servers" connected via VPN.
On the main server there exists a table which has to be replicated daily to all the child servers to keep them synchronized.
SQL's replication is not an option here for many reason I'm not going into right now.
But when I execute one SP within another, a time-out occurs (I think) on when updating some child servers. If I execute the SP seperately (not from another SP) it works fine, even though it runs for more than 3minutes.
|
|
|
|
|
Hi,
I just wanted to know if there are any 3rd party tools available that provide the user with an interface similar to that of SQL Builder which can be used with a windows application to allow the end user to design his own reports.
Thanks
|
|
|
|
|
Never give an end-user that kind of control/options, they'll find some way of mocking up.
I had a quick look and it seems Oppen Office has something[^] similar to what you described.
Sorry if it's not spot on, I don't know of any tool that is simple enough for end users to use.
|
|
|
|
|
hi all
i want to create query which gives me
1) all Table name of the selected Database
2) all fields name of selected Table
thanks in advance
The Stifler
--
Bugs can neither be created nor be removed from software by a developer. They can only be converted from one form to another. The total number of bugs in the software always remain constant.
|
|
|
|
|
Assuming you are talking about SQL Server
The Stifler wrote: 1) all Table name of the selected Database
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'
The Stifler wrote: 2) all fields name of selected Table
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'MyTableName'
|
|
|
|
|
Thanks Colin
The Stifler
--
Bugs can neither be created nor be removed from software by a developer. They can only be converted from one form to another. The total number of bugs in the software always remain constant.
|
|
|
|