At last a working VB 2010 data application linked to a SQL Server 2008 instance. In the end I used two methods.
Method 1: Extreme coding. I used sample data provided by aptly named PsychoCoder in http://www.dreamincode.net/forums/topic/32392-sql-basics-in-vbnet/. He obviously doesn't test his posted code, there were a number of errors in it but not too hard to sort out. I couldn't get his code to work with a connection string embedded in app.config but with a hard-coded string it worked as far as it went and showed me a filled DataGridView. That's about where it ended - I couldn't work out from there how to actually do anything useful like update back to the database (he provides code but doesn't suggest where to hang it in a datagrid). However, that clearly showed that with the appropriate connectiions the two systems could talk.
Method 2: Permissions kludge. In the VB data access wizard there is an option to connect to a SQL Server mdf file, but if you try to do that and point it at your SQL database it can't access the file. So I did a few tweaks. I used the advanced settings to select the appropriate SQL Server instance (the 32 bit one as that was where I'd managed to populate some data) and I set it to not use a user instance (that was suggested by a few forum posts). I then changed the permissions on the actual MDF file (it was in C:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS32\MSSQL\DATA\FamilyHistory_Data.mdf, your mileage may vary) so the group Users had the same permissions as the SQL users group. Administrators already have those permissions but for some reason UAC doesn't pop up to ask if you want to use them so you have to access as Users. Bingo! the wizard completed and I can use the full might of Visual studio and Visual Basic to manipulate my data. It would be easier if the connection used SQL Server to access the data instead of piling in as if it was a private file, but at least it works. I suspect if you buy the non-Express versions there's an option to go through SQL Server.
Now to write the application. My Access database has developed over many years, so I don't know how much functionality I can get in before something else arrived to take up my time, but here goes.
First, I probably need to rewrite the database to use text strings for dates and a class to provide date checking and arithmetic based on those strings.
Tuesday, 14 December 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment