Jump to content

vb.net with access


Matar

Recommended Posts

hi am trying to insert a data into access database with vb.net interface (2005)the porplem is the adding is completed succeful in the dataset only not in the real database this is the code **** Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Nwind.mdb") Dim sql As String = String.Empty sql = "INSERT INTO Categories (CategoryID,CategoryName,Description)" & "values('" & txtid.Text & "','" & txtname.Text & "','" & txtdes.Text & "')" conn.Open() Dim command As New OleDb.OleDbCommand(sql, conn) command.ExecuteNonQuery() conn.Close()*********what's UP ?

Link to comment
Share on other sites

I see two possible explanations. The first would be your connection string. Are you able to retrieve data from the database using that connection string? I'm not sure about VB, but in C# "\n" is the special character for a newline. Maybe the "\N" in "\Nwind.mdb" is causing the problem.More likely, however, it's because of your query. There is no space between the first set of parentheses and the VALUES keyword. The query is coming out like:

INSERT INTO Categories (CategoryID,CategoryName,Description)values(...

Where it probably ought to be:

INSERT INTO Categories (CategoryID,CategoryName,Description) values (...

Link to comment
Share on other sites

  • 2 weeks later...

hi am sorry for this late i make jesh but the data also added just to the dataset not to the orginal database ... pulpfiction ... there is no error the poroblem is that the data i add to the database via vb.net interface just inserted to the dataset so when i close the application no data added to orginal database ... thank you all matar

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...