|
Hi!
I need some advice how to retrieve data from an existing MySQL database using .NET Framework.
I’ve earlier retrieved data from an Acces database and then used OleDbConnection successfully. I’ve also used SqlConnection to contact a MS SQL 2000 Server.
In which way should I do the suff with my MySQL database?
Thanks
...and justice for all
APe
|
|
|
|
|
|
Hi,
I am using sql server 7.0 in that i am having a table of 3 feild i.e.
empName, Logindate, HoursWorked
select * from tablename
Result:
empName LoginDate HoursWorked
------- ------------ ------------
Amit 06/03/04 13:44:45
Amit 06/04/04 14:44:45
now i want the sum of the field "HoursWorked"
Can any body help?
|
|
|
|
|
Your results are a little confusing. What is the data type of HoursWorked?
|
|
|
|
|
Actually im taking 'LoginTime' and 'LogoutTime' Datatype
'DateTime' from "login" table and subtraction of this two field is strored in field 'TimeDiffrence' datatype varchar
Query i m using is
"convert(varchar(8),(logoutTime-loginTime),14)Timediffrence"
now i want the sum of the field "Timediffrence"
|
|
|
|
|
hi, i got a question about published the report in access. I use the following code to open the report: DoCmd.OpenReport "Result", acViewPreview, , Query1, acWindowNormal it is working.
But when I using the following code instead: DoCmd.OpenReport "Result", acViewPreview, , "SELECT * FROM Customers WHERE Customers.CustomerID LIKE 'A*'", acWindowNormal it is not running. I just want to use SQL statement instead of query object (Query1). Does anybody knows it problem?
Roath Kanel
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hi all,
This is a query about the usage of SqlDataAdapter class - I would like to know the base or bare minimum requirements that need to be fulfilled in order to use this class.
I have two text boxes - brCode and brName. On the Update button, I have the following code :
dim brDA as new SqlDataAdapter()
.
I declare a brDA.InsertCommand(), and specify the following -
1. Parameters "@brCode" and "@brName" as input parameters. Their .value are set to the text property of the respective textboxes.
2. The .CommandType as a stored procedure that simply does the following -
update <db>
set <fldname> = @parm1
where <fldname> = @parm2
With this, when brDA.Update is called, it expects datatable / row / dataset. In my simple example,
do i still need to create a dataset and populate it with the field values in order to proceed with the Update ? Or should i take an altogether different route instead of the data-adapter ?
Any help shall be appreciated.
Sanjay.
|
|
|
|
|
You can create a SQLCommand object and set the properties to it including CommandText as your SP name, CommadType as 'SP' and add parameters. In your case, params are going to be the two textbox values and then just use SqlCommand.ExecuteNonQuery() which will just execute the SP which will update the underlying table
Bhaskara
|
|
|
|
|
Bhaskara,
Thanks. Will try it out.
Another issue I was struggling with was - in case I _am_ using a data table, and I want to use the DA.Update(), then I just have to initialize the .InsertCommand and am through with the database updation. But if I have to modify an already existing row in the database, then the DA _insists_ that I initialize a .UpdateCommand, _as_ _well_ _as_ a .InsertCommand.
Is that the case, or am I missing some point here ?
Sanjay.
|
|
|
|
|
Yes, you need to set XXXCommands of a DataAdapter. These commands are wisely used by DataAdapter, based on the status of the row in DataSets. Eg. If the row is newly inserted it will use InsertCommand etc.
I suggest you to go thru MSDN. I find it very useful to get more info.
Bhaskara
|
|
|
|
|
Hi
I'm trying to select the latest date entry record for a property out of a table and I thought I could use MAX(productdate), but this only works on it's own, not with other fields in the SELECT from that record. I know I can select all records for that property and sort by date descending but surely there's a better way to do it in SQL to pull all the record details out explicitly without a sort?
Hope you can help,
Patrick Collins
|
|
|
|
|
Hi,
What about this:
SELECT * FROM sales WHERE productdate = (SELECT max(productdate) FROM sales)
HTH,
Thea
|
|
|
|
|
Thank you very much, Thea
Everything & Nothing
http://www.lostsheep.com
|
|
|
|
|
SELECT TOP 1 * FROM table WHERE condition ORDER BY productdata DESC
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Thanks for for that too Colin
Everything & Nothing
http://www.lostsheep.com
|
|
|
|
|
I'm accessing Oracle data using oo4o VB. Here's the problem:
I'd like to update the unique keys like below. How would I
implement it using oo40 oradynaset. If it can't be done,
how to implement it in ADO?
Ukey (Original -> Target Data)
----
10 -> 11
11 -> 12
12 -> 10
Have tried it but there's a unique key violation error
after I call the Oradynaset.Update method for each row.
I use begintrans/committrans.
|
|
|
|
|
I am a little unclear about why you would be doing this from code. Updating primary keys should never be a part of an application, unless it is a one-time fixup of data.
That said, the problem is that the database will not allow 2 items to share a primary key value, even within a transaction. So, the solution would be do it in two steps, e.g.
Step 1
<br />
10 -> 1011<br />
11 -> 1012<br />
12 -> 1010
Step 2
<br />
1011 -> 11<br />
1012 -> 12<br />
1010 -> 10<br />
You could still keep the above in a single transaction.
|
|
|
|
|
Now the database I have has relationships defined through the tables, albiet the design is more implied in the design of the fields and tables. Realizing that MS Access is nothing more than a front end to the Jet Database, is it worth it to setup relationships in MS Access through the Tools/Relationships menu option? That is, it seems in using this menu option it shows subsheets for the tables that have relationships and perhaps you have a design look and feel in the Relationship window, but on a programmical scale is it worth setting this up? What are the benefits in using that menu option?
Thanks!
|
|
|
|
|
Hi there. I would say yes, establish relationships using the front-end provided by Access. Jet will enforce those relationships, and you would rather have the database engine itself enforce data integrity than to code for it in an application.
|
|
|
|
|
I want to Learn Mysql Databse is there andy body who can help me in this regard
Thanks
Jawed
|
|
|
|
|
Try to get the this books "PHP/MySql Programming for the absolute beginner" its ISBN is: 1-931841-32-2. You can purchase it from Amazon.com or use google to search for PHP documentation over the internet.
Roath Kanel
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
|
Hi pls let me know anybody how to insert Photo into database and how to display in webpart using C#.
sree
|
|
|
|
|
If I INSERT data into a table 'table_1' from my C++ application and want the SQL Server to INSERT portions of data from 'table_1' into 'table_2' and 'table_3', how do I solve that in a correct way? Do I have to do INSERR from my C++ application into 'table_2' and 'table_3' or is there a better way to let the SQL Server handle that??
KT
|
|
|
|
|
Put an insert trigger on table_1.
With in the trigger do the insert into table_2 & table_3.
Michael
I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious.
Vince Lombardi (1913-1970)
|
|
|
|