Access problems

Filmgalning

New member
Joined
Sep 2, 2010
Messages
1
Programming Experience
Beginner
I'm used to VB6 and when my old computer died I had to upgrade to vb.net since I couldn't get visual studio to work on my new one. My pet project a movie registration program which was connected to AccesDB with a zillion functions does not work anymore. I have to rewrite the whole thing in VB.net and now the trouble starts.
Problems:
Some of the column names in the Db had not so clever names (like Aspect Ratio etc.) .I can add the data but as soon as there is a column name which is bracketed (in the sql-field) I get a Syntax error in INSERT INTO'statement when I get to the line "objDataAdapter.Update(ds, "tblDVD")".
Any way to solve this? I thought of changing the name of the columns in Access but I don't have Access any more either which complicates the matter.

Code example:
Dim objConn As New System.Data.OleDb.OleDbConnection(sConnection)
Dim ds As New DataSet
'Dim sql As String = "SELECT ID, Title, [Number], Genre, Country, Runtime, Rating, [Language], Subtitles, [Aspect Ratio], [Sound Mix], Color, Extras, [Video Norm], [Region Code], Discs, Format, Packaging, Studio, [THX Certified], [Closed Captioned], [Interactive Menus], [16:9 Enhanced], [Box Set], [Alternative Titles], Director, Producer, Writer, Cinematographer, Editor, Composer, [Cast], [Year] FROM tblDVD"

Dim objDataAdapter As New OleDb.OleDbDataAdapter(Sql, sConnection)
objDataAdapter.Fill(ds, "tblDvd")
Dim cb As New OleDb.OleDbCommandBuilder(objDataAdapter)

'Dim dataset1 As DataSet
Dim newDvdRow As DataRow = ds.Tables("tblDVD").NewRow()
newDvdRow("ID") = "10001"
newDvdRow("Title") = "ABC2"
etc etc......
ds.Tables("tblDVD").Rows.Add(newDvdRow)
objDataAdapter.Update(ds, "tblDVD")

Problem 2. One way to work around the problem described above is to create a new database and transfer all the data from the old one. How do I set AutoIncrement on a column?

Code:
VB6
With .Columns
.Append "ID", adInteger
.Item("ID").Properties("AutoIncrement") = True <--------------------------How do you do this in VB.net?


I hope I made my self clear. It's not always easy to explain what you mean.

/Michael
 
Read the DW2 link in my signature, section Creating a Simple Data Application
Do your data access like that says and all your problems will go away :)

Autoinc in VB.NET with access? you'll struggle because access cannot report back to VB what ID it has just assigned, unlike sql server
 
Back
Top