Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'TODO: This line of code loads data into the 'StudDataSet.student' table. You can move, or remove it, as needed.
Me.StudentTableAdapter.Fill(Me.StudDataSet.student)
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Extern Innovation\Desktop\stud.mdb")
con.Open()
adapter = New OleDbDataAdapter("select * from student", con)
ds = New DataSet()
adapter.Fill(ds, "student")
ds.Tables(0).Constraints.Add("pk_sno", ds.Tables(0).Columns(0), True)
'PictureBox1.Image = Nothing
' If (ds.Tables(0).Rows(rno)(3)!System.DBNull.Value) Then
'photo_array = ds.Tables(0).Rows(rno)(3).ToString
' ms = New MemoryStream(photo_array)
'PictureBox1.Image = Image.FromStream(ms)
' End If
con.Close()
End Sub
Private Sub browseButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles browseButton.Click
Dim res As DialogResult
OpenFileDialog1.Filter = "jpeg|*.jpg|bmp|*.bmp|all files|*.*"
res = OpenFileDialog1.ShowDialog()
If (res = DialogResult.OK) Then
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
End If
End Sub
Private Sub insertButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles insertButton.Click
Dim sno As Integer
Dim sname, course As String
Dim photo As Image
'Dim query As Integer
sno = TextBox1.Text
sname = TextBox3.Text
course = TextBox3.Text
photo = PictureBox1.Image
Dim ms As New MemoryStream
'Dim stream As FileStream
photo.Save(ms, ImageFormat.Jpeg)
Dim data = ms.ToArray()
ms.Close()
'con = New OleDbConnection("insert into student(sno,sname,course,photo) values(" + TextBox1.Text + ",'" + TextBox2.Text + "','" + TextBox3.Text + "',@photo)", con)
con.Open()
Dim str As String = "insert into student values(" & TextBox1.Text & ",'" & TextBox2.Text & "','" & TextBox3.Text & "','" & PictureBox1.ToString & "'"
Dim mycommand As New OleDbCommand
mycommand.Parameters.Add("@sno", OleDbType.VarChar)
mycommand.Parameters.Add("@sname", OleDbType.VarChar)
mycommand.Parameters.Add("@course", OleDbType.VarChar)
' mycommand.Parameters.Add("@photo", OleDbType.VarChar)
mycommand.Parameters("@sno").Value = sno
mycommand.Parameters("@sname").Value = sname
mycommand.Parameters("@course").Value = course
' mycommand.Parameters("@photo").Value = photo
mycommand.CommandText = Text
mycommand.Connection = con
'mycommand.ExecuteNonQuery()
cmd = New OleDbCommand(str, con)
cmd.Parameters.AddWithValue("@photo", photo)
Dim n As Integer
cmd.ExecuteNonQuery()
con.Close()
If (n > 0) Then
Else
MessageBox.Show("insertion failed")
End If
'Dim conv_photo As Convert
'If (PictureBox1.Image!DBNull.Value) Then
' Dim ms As MemoryStream = New MemoryStream()
' PictureBox1.Image.Save(ms, ImageFormat.Bmp)
' Dim photo_aray As Byte
'photo_aray = ms.Read(photo_aray, 0, 0)
'ms.Position = 0
' ms.Read(photo_aray, 0, 0)
' Dim data As IDataObject
' Dim bmap As Image
' Dim ms As New IO.MemoryStream()
'PictureBox1.Image.Save(ms, ImageFormat.Bmp)
'data = Clipboard.GetDataObject()
'If data Is Nothing Then Exit Sub
'If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
'photo = CType(data.GetData(GetType(System.Drawing.Bitmap)), Image)
' photo.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp)
' Image = ms.GetBuffer
'cmd.Parameters.AddWithValue("@photo", photo)
'End If
End Sub
this codeing is save and load image in ms access but is not working so please correct this code .mdb file name stud tabale name is student fildname is photo fild type is olb object
error for :number of query and desination filed are not in same.
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim ray As String
ray = Me.cjTextBox.Text
Dim ray1 As String
ray1 = Me.ptTextBox.Text
Dim ans As String
Dim company, flg2, address, branch, pt, desc, flg, lang, cj, email, path As String
Dim amt As Integer
Me.TextBox5.Text = Me.pathTextBox.Text
Dim fs As New FileStream(TextBox5.Text, FileMode.Open, FileAccess.Read)
Dim bys As New BinaryReader(fs)
Dim bty(fs.Length) As Byte
bys.Read(bty, 0, fs.Length)
fs.Close()
Me.FlgTextBox.Text = "adfcup"
Me.Flg2TextBox.Text = "1"
If Me.RadioButton1.Checked = True Then
Me.LangTextBox.Text = "madrn"
ElseIf Me.RadioButton2.Checked = True Then
Me.LangTextBox.Text = "eng"
End If
If Me.ComboBox1.Text = Nothing Or Me.CjTextBox.Text = Nothing Or Me.PtTextBox.Text = Nothing Or Me.DescTextBox.Text = Nothing Then
MsgBox("Please fill all field")
ElseIf Len(Me.CjTextBox.Text) < 6 Then
MsgBox("Please cj your cj number, should be 6 digit")
Else
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''TO SAVE NUMBER'''''''''''''''''''''''''''''''''''''''''
ans = Val(ray) + Val(1)
If Len(ans) = 1 Then
Me.NumberTextBox.Text = "00000" & ans
ElseIf Len(ans) = 2 Then
Me.NumberTextBox.Text = "0000" & ans
ElseIf Len(ans) = 3 Then
Me.NumberTextBox.Text = "000" & ans
ElseIf Len(ans) = 4 Then
Me.NumberTextBox.Text = "00" & ans
ElseIf Len(ans) = 5 Then
Me.NumberTextBox.Text = "0" & ans
ElseIf Len(ans) = 6 Then
Me.NumberTextBox.Text = ans
End If
ans = Val(ray) + Val(1)
If Len(ans) = 1 Then
Me.numberTextBox1.Text = "00000" & ans
ElseIf Len(ans) = 2 Then
Me.numberTextBox1.Text = "0000" & ans
ElseIf Len(ans) = 3 Then
Me.numberTextBox1.Text = "000" & ans
ElseIf Len(ans) = 4 Then
Me.numberTextBox1.Text = "00" & ans
ElseIf Len(ans) = 5 Then
Me.numberTextBox1.Text = "0" & ans
ElseIf Len(ans) = 6 Then
Me.numberTextBox1.Text = ans
End If
Me.Validate()
Me.cjnoBindingSource.EndEdit()
Me.CjnoTableAdapter.Update(Me.CjnoDataSet.cjno)
number of query and desination filed are not in same.
[QUOTE=manikandan75;2101513]error for :number of query and desination filed are not in same.
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim ray As String
ray = Me.cjTextBox.Text
Dim ray1 As String
ray1 = Me.ptTextBox.Text
Dim ans As String
Dim company, flg2, address, branch, pt, desc, flg, lang, cj, email, path As String
Dim amt As Integer
Me.TextBox5.Text = Me.pathTextBox.Text
Dim fs As New FileStream(TextBox5.Text, FileMode.Open, FileAccess.Read)
Dim bys As New BinaryReader(fs)
Dim bty(fs.Length) As Byte
bys.Read(bty, 0, fs.Length)
fs.Close()
Me.FlgTextBox.Text = "adfcup"
Me.Flg2TextBox.Text = "1"
If Me.RadioButton1.Checked = True Then
Me.LangTextBox.Text = "madrn"
ElseIf Me.RadioButton2.Checked = True Then
Me.LangTextBox.Text = "eng"
End If
If Me.ComboBox1.Text = Nothing Or Me.CjTextBox.Text = Nothing Or Me.PtTextBox.Text = Nothing Or Me.DescTextBox.Text = Nothing Then
MsgBox("Please fill all field")
ElseIf Len(Me.CjTextBox.Text) < 6 Then
MsgBox("Please cj your cj number, should be 6 digit")
Else
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''TO SAVE NUMBER'''''''''''''''''''''''''''''''''''''''''
ans = Val(ray) + Val(1)
If Len(ans) = 1 Then
Me.NumberTextBox.Text = "00000" & ans
ElseIf Len(ans) = 2 Then
Me.NumberTextBox.Text = "0000" & ans
ElseIf Len(ans) = 3 Then
Me.NumberTextBox.Text = "000" & ans
ElseIf Len(ans) = 4 Then
Me.NumberTextBox.Text = "00" & ans
ElseIf Len(ans) = 5 Then
Me.NumberTextBox.Text = "0" & ans
ElseIf Len(ans) = 6 Then
Me.NumberTextBox.Text = ans
End If
ans = Val(ray) + Val(1)
If Len(ans) = 1 Then
Me.numberTextBox1.Text = "00000" & ans
ElseIf Len(ans) = 2 Then
Me.numberTextBox1.Text = "0000" & ans
ElseIf Len(ans) = 3 Then
Me.numberTextBox1.Text = "000" & ans
ElseIf Len(ans) = 4 Then
Me.numberTextBox1.Text = "00" & ans
ElseIf Len(ans) = 5 Then
Me.numberTextBox1.Text = "0" & ans
ElseIf Len(ans) = 6 Then
Me.numberTextBox1.Text = ans
End If
Me.Validate()
Me.cjnoBindingSource.EndEdit()
Me.CjnoTableAdapter.Update(Me.CjnoDataSet.cjno)
I am closing this thread now, as you got no intention of formatting your code properly. start a new thread with propet code tags, as i've described in post #2.
Like it, don't like it - you expect help, we expect common curtosy.
Bookmarks