I am following this tutorial here http://support.microsoft.com/default.aspx?scid=kb;en-us;308042 the only thing I have changed it the field names in the tables.
but I get the following error message on this code when I debug it
Error: Column 'img_id' does not allow nulls
but I get the following error message on this code when I debug it
Error: Column 'img_id' does not allow nulls
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] fs [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] FileStream _[/SIZE]
[SIZE=2]([/SIZE][SIZE=2][COLOR=#800000]"C:\test_img.jpg"[/COLOR][/SIZE][SIZE=2], FileMode.OpenOrCreate, _[/SIZE]
[SIZE=2]FileAccess.Read)[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] MyData(fs.Length) [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Byte[/COLOR][/SIZE]
[SIZE=2]fs.Read(MyData, 0, fs.Length)[/SIZE]
[SIZE=2]fs.Close()[/SIZE]
[SIZE=2]conn.Open()[/SIZE]
[SIZE=2]da.Fill(ds, [/SIZE][SIZE=2][COLOR=#800000]"db_img"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myRow [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataRow = ds.Tables(0).NewRow[/SIZE]
[SIZE=2]myRow([/SIZE][SIZE=2][COLOR=#800000]"img_name"[/COLOR][/SIZE][SIZE=2]) = [/SIZE][SIZE=2][COLOR=#800000]"Name of Image"[/COLOR][/SIZE]
[SIZE=2]myRow([/SIZE][SIZE=2][COLOR=#800000]"img_type"[/COLOR][/SIZE][SIZE=2]) = MyData[/SIZE]
[SIZE=2]ds.Tables([/SIZE][SIZE=2][COLOR=#800000]"db_img"[/COLOR][/SIZE][SIZE=2]).Rows.Add(myRow)[/SIZE]
[SIZE=2]da.Update(ds, [/SIZE][SIZE=2][COLOR=#800000]"db_img"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]fs = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE]
[SIZE=2]MyCB = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE]
[SIZE=2]ds = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE]
[SIZE=2]da = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE]
[SIZE=2]conn.Close()[/SIZE]
[SIZE=2]conn = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE]
[SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#800000]"Image saved to database"[/COLOR][/SIZE][SIZE=2])[/SIZE]