|
I solved the problem.
I installed ADO 2.8 SP1 and it works again.
|
|
|
|
|
I want to get the primary Key of the selected row in DataGridView when double clicked ...
You know in .net 1.1 we had a datagrid with DataKeyField property to save a special field of table like primary key field. but in DataGrid 2.0 or in DataGridView 2.0 this property disapeared...
Now! how can I get PK when a row selected ?
|
|
|
|
|
I'm using DataGrid 2.0, and I'm pretty sure that "DataKeyField" property still exists in DataGrid 2.0 .
Was it a cat I saw?
|
|
|
|
|
amin_be,
i find it easiest to simple add an invisible and disabled label with the text set to the relevent column of the database, then simply retrieve the label.Text when required.
munklefish
|
|
|
|
|
so, I have to work on my software project for a BTEC national diploma in computing but unfortunately I don't have the support I need from my teacher...
now, i won't go into the detail of the project. what i'd like to talk about is how to go about (the methodology, no actual code...) doing a load, modify, and save to a mySQL database.
I know the code, how to load and save. what i can't get straight is which of these (or any other if better) should i do:
load into dataset, modify by rows and columns, update changes
(this doesn't sound very OOP to me, i hate the idea of having to work with ds.tables[0].rows[0][1] and stuff all the time hehe)
load into dataset, parse into objects and arrays, then dump into dataset and save all
(this sounds very inefficient since saving a lot of records takes time... changing only one record doesn't count here because i would have cleared all dataset and redumped all the data which counts as 'modified' and thus the program will save all records)
load into dataset, parse, dump all data including modifications into new dataset, compare with original dataset, change modified rows only, save old dataset (with modifications)
(this seems the best option because the program will only upload the modified rows... what scares me is : what happens if i delete the first record? all rows will have to shift and thus count as modified, and we still get the inefficiency problem!!)
//god ... now i'm lost
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
In life truth does not matter. What really matters is what others believe to be the truth. (- m4nti)
|
|
|
|
|
il_manti wrote: load into dataset, modify by rows and columns, update changes
I hate that too and I don't use it ever.
il_manti wrote: load into dataset, parse into objects and arrays, then dump into dataset and save all
You're right. It is very inneficient - I don't recomment this either.
il_manti wrote: load into dataset, parse, dump all data including modifications into new dataset, compare with original dataset, change modified rows only, save old dataset (with modifications)
Unfortunately this is still inefficient - also, remember that you should be treating this data as a "set" - i.e. there is no specific order of the items in it.
What I sometimes do is:
* Load into my objects using a DataReader (that is what the data adapter is doing anyway when it populates the DataSet - I might as well remove one step, and save a lot of memory)
* You might want to consider adding a dirty flag (initial value false ) to your objects and make sure you access them via properties or methods only - no direct access you your object's fields (member variables). So any call to a set property would set the dirty flag to true .
* Update the database by applying only those objects where the dirty flag is set to true .
You might also want to look at an open source product called NHibernate which is at http://www.hibernate.org/[^]
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
-- modified at 2:55 Friday 7th April, 2006
|
|
|
|
|
thanks a lot for the 'dirty flag' idea. i'll work on it.
i talked to another lecturer (the best in school) about this and he lectured me on the difference between object-relational and object-oriented theories... he also said people are still trying to code perfect a bridge between the two "worlds" (DLinq or something like that was one of the names he mentioned).
i'll see what i can do, thanks a lot for the reply
- m4nti
In life truth does not matter. What really matters is what others believe to be the truth. (The Up and Comer - Book)
|
|
|
|
|
Cant get this code to work!? I need to write stuf to my database (access), but it wont work.
The errormessage I get says:
"
Operation must use an updateable query.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Operation must use an updateable query.
"
What do they mean with an updateble query???
////// C O D E \\\\\\\\
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dbconn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source = C:\Inetpub\wwwroot\IED416\ied416lp3_19\db\handel.mdb")
Dim dbinsert As OleDb.OleDbCommand
dbconn.Open()
dbinsert = dbconn.CreateCommand
dbinsert.CommandText = "INSERT INTO Kunder (Namn,Ort) VALUES ('Christian','Sweden')"
dbinsert.Connection = dbconn
dbinsert.ExecuteNonQuery()
MsgBox("Weee")
dbconn.Close()
End Sub
////// C O D E \\\\\\\\
|
|
|
|
|
Import System.Data.OleDb
.
.
.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dbconn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;data source = C:\Inetpub\wwwroot\IED416\ied416lp3_19\db\handel.mdb")
Dim dbinsert As OleDbCommand;
dbconn.Open()
dbinsert.Connection = dbconn
dbinsert.CommandText = "INSERT INTO Kunder (Namn,Ort) VALUES ('Christian','Sweden')"
dbinsert.ExecuteNonQuery()
MsgBox("Weee")
dbconn.Close()
End Sub
Question:
'Your table Kunder does have only two columns (Name and Ort)?
|
|
|
|
|
Hmm no... 3 coloums
ID, Name, Ort
ID is autoincreasment.
|
|
|
|
|
If is AutoNumber it should work your code (modified by me) posted before.
|
|
|
|
|
Errormessage:
Type 'OleDbConnection' not defined
Type 'OleDbCommand' not defined
Where should this code be? >>Import System.Data.OleDb<< and what is the meaning with it?
I get error on 'Import', cause of "Declaration expected" ...
What to do? I use Visual Basic.Net
|
|
|
|
|
Imports.System.Data.OleDb
.
.
.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strconn As String
strconn = "Provider=Microsoft.Jet.OleDb.4.0;data source = C:\Inetpub\wwwroot\IED416\ied416lp3_19\db\handel.mdb"
Dim dbconn As OleDbConnection = New OleDbConnection(strconn)
Dim dbinsert As OleDbCommand = New OleDbCommand("INSERT INTO Kunder (Namn,Ort) VALUES ('Christian','Sweden')", dbconn)
dbconn.Open()
dbinsert.ExecuteNonQuery()
MsgBox("Weee")
dbconn.Close()
End Sub
Imports.System.Data.OleDb means that you are using OLEDB Provider for your database
for more info check this
|
|
|
|
|
It give me error when I write this code.
'Import' statements must precede any declarations.
Imports.System.Data.OleDb
'''''''
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click
Dim dbconn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source = C:\Inetpub\wwwroot\IED416\ied416lp3_19\db\handel.mdb")
Dim dbinsert As OleDb.OleDbCommand
dbconn.Open()
dbinsert = dbconn.CreateCommand
dbinsert.CommandText = "INSERT INTO Kunder (Namn,Ort) VALUES ('Christian','Sweden')"
>> dbinsert.CommandText = "UPDATE Kunder SET (Namn='Christian',Ort = 'Sweden')"
dbinsert.Connection = dbconn
dbinsert.ExecuteNonQuery()
MsgBox("Weee")
dbconn.Close()
End Sub
I also tried the line of code with UPDATE, but it didnt work.
Pleeze help me!!!
|
|
|
|
|
1. Double click in button and go on top of the class and write this line of code Imports.System.Data.OleDb
2. Code which i modified at least time must work (must insert data in your dataabse)
3. When you try to update data you should based in ID of that row. (ID is Autonumber as you said)
4. Can you share here your update code
5. Did you check link which i have posted before?
|
|
|
|
|
I did check the link.
But I dont get any smarter =)
The code you wrote dont work, look at the picture.
Picture
When I delete the ";" all the errors dissaears, but then I get the errormessage: "Object reference not set to an instance of an object."
The line of code... Imports.System.Data.OleDb I need to write without the first dot, like this: Imports System.Data.OleDb, do you work in the same program like me?
|
|
|
|
|
1. You have right that for importin OleDb namespace it should be like this Imports System.Data.OleDb
2. Delete ';' and debug your appliaction
here is correct code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Dim strconn As String<br />
strconn = "Provider=Microsoft.Jet.OleDb.4.0;data source = C:\Inetpub\wwwroot\IED416\ied416lp3_19\db\handel.mdb"<br />
Dim dbconn As OleDbConnection = New OleDbConnection(strconn)<br />
Dim dbinsert As OleDbCommand<br />
dbconn.Open()<br />
dbinsert.Connection = dbconn<br />
dbinsert.CommandText = "INSERT INTO Kunder (Namn,Ort) VALUES ('Christian','Sweden')"<br />
dbinsert.ExecuteNonQuery()<br />
MsgBox("Weee")<br />
dbconn.Close()<br />
<br />
End Sub
|
|
|
|
|
|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Dim strconn As String<br />
strconn = "Provider=Microsoft.Jet.OleDb.4.0;data source = C:\Inetpub\wwwroot\IED416\ied416lp3_19\db\handel.mdb"<br />
Dim dbconn As OleDbConnection = New OleDbConnection(strconn) <br />
dbconn.Open()<br />
Dim dbinsert As OleDbCommand = New OleDbCommand("INSERT INTO Kunder (Namn,Ort) VALUES ('Christian','Sweden')", dbconn)<br />
dbinsert.ExecuteNonQuery()<br />
MsgBox("Weee")<br />
dbconn.Close()<br />
<br />
End Sub
|
|
|
|
|
>>> Code <<<<
>>> E-message <<<<
My knowledge of these problem is very finite
Im very thankful of ur help!!
|
|
|
|
|
Dude this code below works 100% and your duty is just to copy from here and paste in your project
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
<br />
Dim strconn As String ' here declare string variable for instance of OleDbConnection<br />
strconn = "Provider=Microsoft.Jet.OleDb.4.0;data source = C:\Inetpub\wwwroot\IED416\ied416lp3_19\db\handel.mdb" ' here initialize string variable by givin string of conenction<br />
Dim dbconn As OleDbConnection = New OleDbConnection(strconn) 'here initialize OleDbConnection with string variable<br />
dbconn.Open() 'Here open OleDb connection string<br />
Dim dbinsert As OleDbCommand = New OleDbCommand("INSERT INTO Kunder (Namn,Ort) VALUES ('Christian','Sweden')", dbconn) 'Here is initialize of OleDbCommand and here you get your error but if you use this code you should not get any error<br />
dbinsert.ExecuteNonQuery() 'Here executed OleDbCommand <br />
MsgBox("Weee") 'Here Display MessageBox with string Weee<br />
dbconn.Close() ' Here Closed your connection string<br />
<br />
End Sub
-- modified at 6:04 Friday 7th April, 2006
|
|
|
|
|
He isn't learning anything by copying and pasting your code.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
I see he can't because i tyed to explain so so simple little insert command until i wrote him just to copy and paste.
|
|
|
|
|
I am trying to add an assembly to a SQL2005 database but am getting the following error:
Warning: The SQL Server client assembly 'microsoft.sqlserver.smo, version=9.0.242.0, culture=neutral, publickeytoken=89845dcd8080cc91, processorarchitecture=msil.' you are registering is not fully tested in SQL Server hosted environment.
The code I used was:
CREATE ASSEMBLY Smo
FROM 'C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies\Microsoft.SqlServer.Smo.dll'
WITH PERMISSION_SET = EXTERNAL_ACCESS
I have tried to set the database to be trusted (ALTER DATABASE [dB] Set TRUSTWORTHY ON ) but that does not help.
My end goal is that I need to access some SMO (SQL Management Objects, replaces SQL-DMO) methods in a SqlServerProject. You first have to add the assembly to your database though before you can Add Reference in VS2005.
regards,
Paul Watson
Ireland
Feed Henry!
eh, stop bugging me about it, give it a couple of days, see what happens.
|
|
|
|
|
I need to decide between SQLite or Access Data Base, to build dynamically in a c++ project.
Can you please give me advantages and disadvantages for each one, and advice me wich one to use?
aukh
|
|
|
|