|
I have a dataset with two tables Client (daClient) & Log. (daLog)
I have a combobox bound to the Client table of the dataset filling with the Client column
The FlexGrid is bound to the Log Table and is filled based on the SelectedValue of the combobox. My problem is, to update the Grid based on the selection of the combobox to pull only logs matching the ClientID I need to clear and refill dataset1.Log only. If I just dataset1.clear() I will lose the information in the combobox.
I tried daLog.Tables("Log").clear but this doesn't work.
Right now, the Grid fills with ClientID 6's rows because that is what is in the combobox when I load the form. I set the selectcommand parameter to get combobox1.SelectedValue on load of the form.
I hope this isn't confusing and if so, I can go into more detail with specific settings to objects. The only thing I can say right now is that when changing the combobox to another client, I get the new information in the grid but the old information remains so I now have 2 client's rows in the grid. If I click on one of the items in the grid, the combobox changes to show that client in the combobox. I don't really need this since I only want to display the selected clients information.
Thanks,
Charlie
|
|
|
|
|
I'm not sure that I understand what you want to do.
I'll interpret the SQL you've got and let me know which bits you need different to what you have already.
UPDATE table -- The updates are on the table
-- named "table"
SET field = field + intvariable -- The field named "field" is being updated
-- The new value is the addition of the
-- existing "field" value plus the value in
-- field named "intvariable"
WHERE otherfield = yes -- Apply this update only on records where
-- the field "otherfield" is yes
From your naming convention here, I am thinking that "intvarible" is something that is not in the database already. Is that right? If yes then:
(1) Is "intvariable" the same value for all instances where "otherfield = yes"?
(2) Is "intvariable" different for each record that you want to update?
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|
|
Okay, I've got the files you sent me. So that everyone else understands what is happening I'll explain a little about what was sent.
I received a database with a table called "tsttbl", that table contained a field called "value". The important part of the code I have copied below.
For to help, I've numbered the lines.
1 void Button1_Click(Object sender, EventArgs e)
2 {
3 string str = TextBox1.Text;
4 int num = Convert.ToInt32(str);
5 string strConnect = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source="+Server.MapPath(".\\db\\tstdb.mdb");
6 string strupdate = "UPDATE tsttbl SET value = value + str";
7
8
9 }
In line 6 you define the SQL statement you use to update the database. What this says is: Update all records (because there is no where clause) in tsttble and set the value field to be its current value plus the value of the str field. However there is no str field in the database.
I am guessing, because you've not said, that the str value that you really want is the one defined on line 3. If this is correct change line 6 to:
string strupdate = string.Concat("UPDATE tsttbl SET value = value + ",num.ToString());
I've used num instead of str because num is guaranteed to be a valid integer.
I hope all this helps.
Regards,
Colin.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|
|
HI
I think the best way is to put the number value in a parameter and add the parameter in the command object then use it in SQL statment it is better than paste it in the string of SQL statment by using var.toString()
|
|
|
|
|
Is it possible from my program to change a password for an Access database?
I'm building an application that has to store restricted information in an Access database. In Access, the program itself, you can change password (at least you can remove and re-add a password, not really "change").
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
I have been reading various articles where bitmaps, excel files, pdf files, etc... are being inserting into a column of a database table. Out of curiosity, why are developers doing this and what are the benefits?
|
|
|
|
|
:-DIn my understanding, let's say you have an employee database, and you want to store employee pictures as well in the database along with the name and other information. In that case you may want to store it as a bit map.
Also alot of business are still receiving documents as a hard copy, and to keep the paper trail at one place, they scan the document and upload it to the Database.
This is just few of the many reasons why bit map, and files are inserted to DB.
Hope this helps
Ruchi
|
|
|
|
|
My windows form consists of a datagrid which is populated with the records from the database. When i select a row using HitTest property the data is displayed in the textboxes that i have on my form.I hava an update button which updates this selected data to the database.User can change the data that is displayed in the textboxes.
My question is : I am not able to update this changed data to the database.
Please help.
My code is in c#
Thanks
|
|
|
|
|
My windows form consists of a datagrid which is populated with the records from the database. When i select a row using HitTest property the data is displayed in the textboxes that i have on my form.I hava an update button which updates this selected data to the database.User can change the data that is displayed in the textboxes.
My question is : I am not able to update this changed data to the database.
Please help.
Thanks
|
|
|
|
|
How to handle BLOB in datasets.
Examples if any ??
|
|
|
|
|
Did you try to convert the dataset data to byte array?
byte[] bytes=(byte[])ds.Tables[0].Rows[0][0]
Than convert the byte array to the data you want.
|
|
|
|
|
Hi, I want to open mdb file (access 2003) using DAO but i get an error that the file is not exist despite the fact that it exist in the specfic path.is there a problem using DAO in this version?
can anyone send me a simple example how can i do it with ADO instead???
|
|
|
|
|
Ye gods, he said Visual Basic 6, and you can't use an OLE DB connection string with the SqlConnection class in the .NET Framework anyway.
Ahem.
Right, a useful answer to the question: when working with ADO, I can't usually be bothered to set up the connection string myself. I use Windows' built-in Universal Data Link tool.
Create a new, empty text document somewhere. Rename it so that the extension is '.udl'. The icon should change to what looks like a computer in front of a database table. Open the file.
You should get a property sheet titled "Data Link Properties". Choose the Provider tab and select "Microsoft Jet 4.0 OLE DB Provider". Click the Connection tab or the Next>> button. Continue making settings as appropriate.
You can now open the file with Notepad, or any other text editor. Inside you'll see the following:
[oledb]
; Everything after this line is an OLE DB initstring
Provider=Microsoft.Jet.OLEDB.4.0;Data Source= (etc) Copy the third line to the clipboard, we'll need it in a moment.
In VB6, use the References box to add a reference to "Microsoft ActiveX Data Objects 2.5 Library". You could also use 2.6, 2.7 or 2.8 if you have a higher version installed, but they don't offer much more functionality for simple data access, and you'd have to ensure the end-user has this version. MDAC 2.5 came with Windows 2000.
You can now access your data, for example:
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As ADODB.Recordset
conn.ConnectionString = _
"connection string from UDL file"
conn.Open
cmd.CommandText = "select command"
cmd.CommandType = adCmdText
cmd.ActiveConnection = conn
Set rs = cmd.Execute(, , adOpenForwardOnly Or adLockReadOnly) You could also use rs.Open instead of cmd.Execute .
|
|
|
|
|
Need help....
How do I combine the following two statements? I'm using them in ASP connected to Access DB.
SqlJunk = " SELECT SUM(MSD+Methods+Analysis+Architectures+Models+Studio+Elective1+Elective2+Elective3) As PersonTotals FROM tblpersons "
SqlJunk = SqlJunk & " WHERE User_Id=" & Request.Form("DaInBox")
SqlJunk = "SELECT FirstName, LastName, WeekNo, ProgramName, StudioTeamName FROM tblpersons"
SqlJunk = SqlJunk & " WHERE User_Id=" & Request.Form("DaInBox")
When I run them independantly they work but I don't know how to combine them
Thanx
|
|
|
|
|
Is User_Id your primary key?
Two ways:
1. User_Id is your primary key then:
SELECT (MSD + Methods + Analysis + Architectures + Models +
Studio + Elective1 + Elective2 + Elective3) As PersonTotals,
FirstName, LastName, WeekNo, ProgramName, StudioTeamName
FROM tblpersons
2. User_Id is NOT your primary key
SELECT SUM(MSD + Methods + Analysis + Architectures + Models +
Studio + Elective1 + Elective2 + Elective3) As PersonTotals,
FirstName, LastName, WeekNo, ProgramName, StudioTeamName
FROM tblpersons
GROUP BY FirstName, LastName, WeekNo, ProgramName, StudioTeamName
Without knowing more about your datamodel I can't guarantee they they will produce the expected results.
Where you appeared to be going wrong was that the SUM() function is an aggregator function (It operates on lots of records). If User_Id was your primary key then it was operating on only one record so there was nothing to aggretate. If User_Id was not your primary key then you need to specify the fields to GROUP BY that you want to output but are not part of the input to the aggretate function.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|
|
Friends,
I am in search of resources from which i can learn about the database concurrency issues related to .NET, Oracle and MS-Access. I've found number of resources related to SQL-Server and .NET. But unable to find resoures related to MS-Access and Oracle. Can you tell me how concurrency issues are handled in Access and Oracle Or give me some good resources.
Thanks
|
|
|
|
|
I want to create some stored procedures, but my server database is read-only. Is there any way that I can create a local database (like MS-Access) and then I can save my stored procedures there? It is important to point out that the application is going to run in computers that do not have Office installed (meaning that ACCESS is not an option to work with, only to create from outside such database with read/write privilegies). Any input is really appreciated. Thanks ..
PS I logged on like 30 times and every time I tried to post my message I got the error that I am not logged on. This is frustrating
|
|
|
|
|
Anonymous wrote:
PS I logged on like 30 times and every time I tried to post my message I got the error that I am not logged on. This is frustrating
Do you have cookies enabled?
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|
|
Hello, I have a c# code file and within it I have the following code:
private void Page_Load(object sender, System.EventArgs e)
{
DBReader("SELECT PackageNumber FROM Packages WHERE Packages.PackageID = Level1Packages.PackageID");
}
private void DBReader(string SQLQuery)
{
if(!IsPostBack)
{
OleDbCommand myCommand = new OleDbCommand(SQLQuery,oleDbConnection1);
oleDbConnection1.Open();
dataReader = myCommand.ExecuteReader(); *******
while(dataReader.Read())
{
this.Lvl1PackageNumListBox.Items.Add(dataReader.GetString(0));
}
oleDbConnection1.Close();
}
}
The code dies on the line with stars with the error message "no value given for one or more parameters". I think the problem lies in my SQl statement I am passing to the DBReader method. I am not sure if using the . operator is correct when trying to access a column of a table. Thanks for helping out a newbie!
Frank
|
|
|
|
|
Going out on a limb here, but change the SQL to be
SELECT PackageNumber FROM Packages,Level1Packages WHERE Packages.PackageID = Level1Packages.PackageID,
Chris Meech
It's much easier to get rich telling people what they want to hear. Chistopher Duncan
I can't help getting older, but I refuse to grow up. Roger Wright
I've been meaning to change my sig. Thanks! Alvaro Mendez
We're more like a hobbiest in a Home Depot drooling at all the shiny power tools, rather than a craftsman that makes the chair to an exacting level of comfort by measuring the customer's butt. Marc Clifton
|
|
|
|
|
I'm connecting to a database via DSNs. I want to figure out if I'm woring with MSSQL, Oracle or Access. Using ADO or MCF ODBC classes. How?!
|
|
|
|
|
|
I think you need to use SQLGetInfo once you've opened the connection, passing the SQL_DRIVER_NAME value for the InfoType parameter. That's based on my reading of the documentation.
You could also try SQL_DATABASE_NAME or SQL_DBMS_NAME .
When using ADO with a DSN, you're actually using the MSDASQL provider, which is basically a translation layer on top of ODBC. It may be possible to retrieve the underlying ODBC connection handle by looking at the Properties collection of the ADO Connection object.
|
|
|
|
|
Hi!
I am trying to drop a login but it owns a few databases. I know about the sp_changedbowner sproc, but I'd like to know if there's a way to remove the ownership per user (for all dbs)... for example: sp_removeownership 'login'.
I need to do this before dropping a login that owns some databases. Database is MS-SQL.
Thanks!
Carl
|
|
|
|
|
I am creating an application for a local education company that is basically an off line tutorial application.
They eventually wish to download the application and start up files then use explorer to pull more files in as the students progress, but for the time being a simple distributed application on their network locally.
I have created a simple MFC single doc application, and the view class is based on HTMLview, this allow me to load HTML files into the app easily.
I have decided to create the pages to be loaded by using a script language (haven't decided which one yet) within HTML doc's.
My question is can i use SQL to store and retrieve HTML files, My idea was to load the files into an SQL database, then use a simple CDatabse class or maybe ADO to load and unload the files, probably ADo since it is more flexible. if i can, then this is a great advantage since the target network has SQL.
Am i trying to be too ambitious, is there an easier way to manage these files from a central location using windows, the pages need to be loaded in sequence.
Any responses are greatly appreciated, i do not wish to code from scratch
Thanks to all whom respond.
Joe.A
|
|
|
|