Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

str50

@str50
About
Posts
21
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Not able to update database [modified]
    S str50

    i figured out my error. I was not updating the dataset. Thanks for everybody's help on this.

    Visual Basic database help announcement

  • Not able to update database [modified]
    S str50

    I am not able to update database even though I have the code right from what I know. Any help will be appreciated. Here is the code for add record once changes have been made. Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click If Ds1.HasChanges() Then da1.Update(Ds1) MsgBox("done") Else MsgBox("not done") End If End Sub -- modified at 19:57 Wednesday 26th July, 2006

    Visual Basic database help announcement

  • object reference not set to an instance of an object error
    S str50

    Alright. I finally made progress with your help. thanks a lot. But now when I run the program I get the message that I put in "not valid". It is not picking up the record. This is the code I have so far. Any help will be appreciated. Thanks Public Sub New(ByVal Value As String) Dim dsData As DataSet = New DataSet1 Dim stSQL As String Dim backupTable As DataTable = dsData.Tables.Add("testbackup") stSQL = "Select * from testbackup Where barcodeid = '" & Value & "'" 'Database code to return dataset to dsData Dim orderConn As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=backup.mdb;") Dim orderDA As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter("SELECT * FROM testbackup", orderConn) orderConn.Open() Dim custDS As DataSet = New DataSet orderDA.Fill(custDS, "testbackup") orderConn.Close() backupTable.Columns.Add("Barcodeid", Type.GetType("System.Int32")) backupTable.Columns.Add("location", Type.GetType("System.String")) backupTable.Columns.Add("datein", Type.GetType("System.String")) backupTable.Columns.Add("dateout", Type.GetType("System.String")) backupTable.Columns.Add("timein", Type.GetType("System.String")) backupTable.Columns.Add("timeout", Type.GetType("System.String")) backupTable.Columns.Add("comment", Type.GetType("System.String")) Select Case dsData.Tables(0).Rows.Count Case 1 'One Row Returned HasData = True TheData = dsData.Tables(0).Rows(0) Case 0 'No Rows Found HasData = False TheData = Nothing Case Else 'More then one row returned 'Decided how to handle HasData = True TheData = dsData.Tables(0).Rows(0) End Select End Sub This is the code where it says not value. Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click Dim oForm2Data As New Form2.Form2Data(Me.txtbarcodeid.Text) If oForm2Data.HasData Then Form2.Initialize(Me, oForm2Data) Else

    Visual Basic help database tutorial announcement

  • object reference not set to an instance of an object error
    S str50

    Alright I looked at the website and this is what I got out of it. This is what I have so far, but when I run the program now I don't get anything. It does not go to form2. It just stays at form1 even when I hit the search button. I must have done something wrong and I can't figure out. I am trying my best to figure out. Any help will be appreciated. Thanks again Public Sub New(ByVal Value As String) Dim dsData As DataSet = New DataSet("BackupInfo") Dim stSQL As String Dim backupTable As DataTable = dsData.Tables.Add("testbackup") stSQL = "Select * from testbackup Where barcodeid = '" & Value & "'" 'Database code to return dataset to dsData backupTable.Columns.Add("Barcodeid", Type.GetType("System.Int32")) backupTable.Columns.Add("location", Type.GetType("System.Int32")) backupTable.Columns.Add("datein", Type.GetType("System.String")) backupTable.Columns.Add("dateout", Type.GetType("System.String")) backupTable.Columns.Add("timein", Type.GetType("System.String")) backupTable.Columns.Add("timeout", Type.GetType("System.String")) backupTable.Columns.Add("comment", Type.GetType("System.String")) Select Case dsData.Tables(0).Rows.Count Case 1 'One Row Returned HasData = True TheData = dsData.Tables(0).Rows(0) Case 0 'No Rows Found HasData = False TheData = Nothing Case Else 'More then one row returned 'Decided how to handle HasData = True TheData = dsData.Tables(0).Rows(0) End Select End Sub

    -- modified at 16:57 Saturday 22nd July, 2006

    Visual Basic help database tutorial announcement

  • object reference not set to an instance of an object error
    S str50

    I am not sure what to put in that area. Would you be able to help me with that if you don't mind. thanks

    Visual Basic help database tutorial announcement

  • object reference not set to an instance of an object error
    S str50

    can i e-mail you my program, so you can see what is happening. let me know. thanks for your help so far

    Visual Basic help database tutorial announcement

  • object reference not set to an instance of an object error
    S str50

    which database code. I am not sure which one. I wanted to post my program here, but I don't know how to do that. Can you tell me where to initialize my dsdata

    Visual Basic help database tutorial announcement

  • object reference not set to an instance of an object error
    S str50

    at this statement Select Case dsData.Tables(0).Rows.Count

    Visual Basic help database tutorial announcement

  • object reference not set to an instance of an object error
    S str50

    I am getting this error when I run the program. I am not sure how to fix this error, if anybody can help me I will appreciate it. The program has two forms. Form1 has the search textbox and form2 takes the information from form1 and populates form2. I have attached the code for both forms, so you can see what I am talking about. Any help will be appreciated. Thanks Form1 Code: Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click Dim oForm2Data As New Form2.Form2Data(Me.txtbarcodeid.Text) If oForm2Data.HasData Then Form2.Initialize(Me, oForm2Data) Else ' The Data does not exists for the item in the textbox End If End Sub Form2 Code: Dim dt As New DataTable Dim sqlStr As String = "SELECT * FROM testbackup" Dim sqlstr1 As String = "SELECT * FROM history" Dim connstr As String = "Provider = Microsoft.Jet.OLEDB.4.0;" & _ "Data Source = backup.mdb" Dim dataadapter As New OleDb.OleDbDataAdapter(sqlStr, connstr) Public Shared Sub Initialize(ByVal Owner As IWin32Window, ByRef oForm2Data As Form2Data) Dim result As DialogResult Dim frm2 As New Form2 With frm2 'Using TheData Populate each Control on Form2 End With Result = frm2.ShowDialog(Owner) If Result = System.Windows.Forms.DialogResult.OK Then With frm2 'Now update the values in TheData with its value in its Form2 Control End With 'Save Changes oForm2Data.SaveData() End If End Sub Public Class Form2Data Public HasData As Boolean Public TheData As DataRow Public Sub New(ByVal Value As String) Dim dsData As DataSet Dim stSQL As String stSQL = "Select * from testbackup Where barcodeid = '" & Value & "'" 'Database code to return dataset to dsData Select Case dsData.Tables(0).Rows.Count Case 1 'One Row Returned HasData = True TheData = dsData.Tables(0).Rows(0) Case 0 'No Rows Found HasData = False TheData = Nothing Case Else 'More then one row returned 'Decided how to handle HasData = True TheData = dsData.Tables(0

    Visual Basic help database tutorial announcement

  • Populate a form
    S str50

    Alright it makes sense now that you explained it. I will try to take what you said and make the changes and see what happens. I don't want you to write my program, just wanted to know how it worked with my situation, since I could not figure it out. Thanks for all your help.

    Visual Basic tutorial database

  • Populate a form
    S str50

    well I tried both. yes i read the article, but that article is bringing up the records in a datagrid and then you select a record and then hit change, but what I want is to put a search field for my example it will be barcodeID and then i hit the search button that is when it should go to the other form and bring up the information. hope that helps. thanks

    Visual Basic tutorial database

  • Populate a form
    S str50

    I tried your suggestion, but with no luck. I was not able to get the information to the other form. I have a search textbox on form2 and when I hit the search button on form2 it should find that record and bring up form1 where there are textboxes and datetimepicker that should be updated automatically according to the record information and I am unable to do that. Any ideas

    Visual Basic tutorial database

  • Populate a form
    S str50

    I tried your suggestion and for some reason I am not able to get information to the other form. Is there anyway you can write me a small program, so I can have a visual presentation of what you are talking about. I would really appreciate that. Please let me know. Thanks

    Visual Basic tutorial database

  • Populate a form
    S str50

    will this work if I have a search textbox in form2 and when I hit the search button on form2 it should go to the database and pull that record out and display all the information on form1 filling in all the textboxes on form1. Please let me know. Thanks for all your help so far.

    Visual Basic tutorial database

  • Populate a form
    S str50

    Hi, I wanted to know how to populate a form once you have done a search on a record. What I am trying to do is that when I search for a record in the access database, once it finds the record I want it to go to another form where I have textboxes and it should populate the information in that form. The search is on a different form, so I have to switch between forms. If anybody can guide me on the right track I will appreciate it.

    Visual Basic tutorial database

  • Null value error
    S str50

    I tried your suggestion and it still did not work. I have a feeling where I have put the code is in the wrong place. In the database barcodeid is a text field. In access database it is a text field. I will paste the code that I have for that button. Thanks for your help again. Private Sub btnUpdateOSSF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateOSSF.Click Dim changes As Integer Dim commandBuilder As New OleDb.OleDbCommandBuilder(dataadapter) Dim i As String Dim str As String Dim comm As New OleDbCommand OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & Application.StartupPath & "\backup.mdb;" comm.Connection = OleDbConnection1 Me.BindingContext(dt).EndCurrentEdit() Dim strWrk As String = dt.Rows(0).Item("DateIN") = DateTimePicker1.Value Dim strWrk1 As String = dt.Rows(0).Item("TimeIN") = DateTimePicker2.Value changes = dataadapter.Update(dt) If changes > 0 Then MsgBox(changes & " changed rows were stored in the database.") Else MsgBox("No changes made.") End If Try OleDbConnection1.Open() 'Copy existing record from original table to history table. comm.CommandText = "INSERT INTO History (barcodeid, Dateout, timeout, location, comments) SELECT barcodeid, Dateout, timeout, location, comments FROM testbackup WHERE barcodeid='" & DgDisplay.Item(DgDisplay.CurrentRowIndex, 0).ToString & "'" comm.ExecuteNonQuery() 'Delete old history record. comm.CommandText = "DELETE FROM history WHERE (barcodeid = '" & DgDisplay.Item(DgDisplay.CurrentRowIndex, 0).ToString & "') AND (ID NOT IN (SELECT TOP 5 ID FROM history where barcodeid = '" & DgDisplay.Item(DgDisplay.CurrentRowIndex, 0).ToString & "' ORDER BY ID Desc))" comm.ExecuteNonQuery() comm.CommandText = "Update testbackup set datein = null, timein = null where barcodeid = ?" If DgDisplay.CurrentRowIndex < 0 Then comm.Parameters.Add("", DBNull.Value) Else comm.Parameters.Add("", DgDisplay.Item(DgDisplay.CurrentRowIndex, 0).ToString) End If comm.ExecuteNonQuery() Catch ex As Exception MsgBox(ex.Message) Err.Clear() Finally O

    Visual Basic help tutorial announcement

  • Null value error
    S str50

    Alright. Well thanks for your help. I don't know how to create them either. Hope somebody can help me. Really appreciate your help so far though.

    Visual Basic help tutorial announcement

  • Null value error
    S str50

    Sorry about not writing in my first post that I am using access as my database. I am not using SQL server. How will the code change and also I am using vb.net 2003 version. Thanks

    Visual Basic help tutorial announcement

  • Null value error
    S str50

    I am using access as my back end for database. I am not using SQL server. Sorry for not letting you know before. Does that change now and how

    Visual Basic help tutorial announcement

  • Null value error
    S str50

    What excatly would I write. Would you be able to help me with that like get me started on the right track. Appreciate it. Thanks

    Visual Basic help tutorial announcement
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups