|
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
|
|
|
|
|
What i have is a sql script that builds tables and other objects and what i
need is to be able to run other filename.sql scripts in side of the first. For instance in oracle, I make an installer.sql and do this:
@createtable.sql
@altertable.sql
@select.sql
@insert.sql
@delete.sql
etc.....
from inside the install.sql so instead of having one really huge sql script i have many smaller ones that all get run from another filename.sql.
|
|
|
|
|
Okey, dokey, boys a girls, heres a fun one. I would like to make a database that i can import into my Visual Studio 2005. For this i usually require a SQL server... I open my Access 2003, and start a new project. I click make a table, and it brings it up... whenever i go to save it says: {TABLE NAME} is not a valid object name... i tried many different names to no avail. any ideas?
"Love, Life and Option Explicit"
|
|
|
|
|
Hi There,
Is it possible to create form at Runtime and when I click on a button create on the new form the data should get stored in database. Please Help.
Regards,
Amit
|
|
|
|
|
Amit R wrote: Is it possible to create form at Runtime and when I click on a button create on the new form the data should get stored in database
Yes.
Have a look at the code that visual studio hides from you - see how it works and implement a similar kind of thing dynamically as per the data you are interested in.
"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
|
|
|
|
|
Here is a simple example,winform Application
//class level var
Form frm =new Form();
Button btn=new Button();
TextBox tb=new TextBox();
//button click event
private void button1_Click(object sender, System.EventArgs e)
{
btn.Text="Click me";
btn.Click+=new EventHandler(btn_Click);
tb.Top=btn.Top+50;
tb.Text="test";
frm.Controls.Add(tb);
frm.Controls.Add(btn);
frm.ShowDialog();
}
private void btn_Click(object sender, System.EventArgs e)
{
MessageBox.Show(tb.Text);
}
|
|
|
|
|
I would like to develop a database application.Its function is to monitor the database actions(etc login,insert,delete),record them and do some auditing. please give me some help.How to implement it.
Thank you very much!
|
|
|
|
|
[Sorry - I misread your question]
You could add triggers to each of the tables and from there put the information you want to audit into some other tables. Your audit application can then query those tables.
"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 3:16 Thursday 6th April, 2006
|
|
|
|
|