Hi All,
My wife is into the slimming world diet and has magazines with her favorite diets marked, so I decided to write her a desktop application so she can save all her recepies and tidy all those magazines.
So please see my code for my breakfast form below
Imports System.Data.SqlClient
Public Class Breakfast
Dim conn As SqlConnection
Dim breakfast As SqlDataAdapter
Dim dsbreakfast As DataSet
Private Sub Breakfast_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
conn = New SqlConnection("Data Source=JOHN-ELLIS-PC;Initial Catalog=SlimmingWorld;Integrated Security=True")
dsbreakfast = New DataSet
breakfast = New SqlDataAdapter("SELECT RedorGreen,Name,Ingredients,Sins,FROM Breakfast", conn)
Dim cmdBuilder As SqlCommandBuilder = New SqlCommandBuilder(breakfast)
breakfast.Fill(dsbreakfast, "breakfast")
DataGridView1.DataSource = dsbreakfast.Tables("Breakfast")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click
breakfast.Update(dsbreakfast, "breakfast")
End Sub
End Class
I am getting an error when I run the program that says "syntax error near the keyword FROM."
Please see below my sql database I wrote
USE [master]
GO
CREATE DATABASE SlimmingWorld
GO
USE SlimmingWorld
GO
CREATE TABLE [dbo].[Breakfast](
[RedorGreen][nvarchar](50) NULL,
[Name][nvarchar](50) NULL,
[Ingredients][nvarchar](50) NULL,
[Sins][nvarchar](50) NULL)
I have spent ages looking for the problem and I just can't see it, can anyone help.
Thanks
John