c# with sql server2008 with horizontal scrollbar.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vishal anand
    New Member
    • Sep 2013
    • 7

    c# with sql server2008 with horizontal scrollbar.

    hi my name is vishal.
    I am currently converting vb6 with ms access to c# with sql server 2008. i am new to horizontal scroll bar in c# with windows forms.

    In Vb6 i have written code for horizontal scrollbar as follows:
    Code:
     myRec.MoveFirst
        myRec.Move scrRec.Value
        lblRecPos.Caption = "Record Pos ( " & scrRec.Value + 1 & "/" & myRec.RecordCount & " )"
        If (myRec.EOF = False) Then
            txtMName.Enabled = False
            txtMSno.Enabled = False
            cboVirology.Enabled = False
            txtMName.Text = myRec("ManufacturerName").Value
            txtMSno.Text = myRec("MFR_SL_No").Value
            cboVirology.Text = myRec("volume").Value
            myRec.MoveNext
        End If
        Exit Sub
    where myRec refers to recordset. The recordset is opening a table named Reprocess in my database.
    Now i do know how to use horizontal scrollbar in c# with sql server 2008 as i used in vb6,adodb with ms access.
    For myRec.EOF=false in c#=> datatable.rows. count==-1.
    Can anyone tell me what is for:
    1)myRec.Move scrRec.Value in c#.
    Anyone please help me.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    I really don't understand what a scroll bar has to do with databases. Scroll bars are User Interface (UI) controls and databases manage data...

    Anyways, I think to get you pointed in the right direction you should probably take a look at this Bytes article on How To Use A Database In Your Program.

    You should probably also use the MSDN Library as a reference when developing any kind of .NET application. This resource contains documentation that will help you understand how to achieve things in .NET. Please note that the search includes things from community forums as well and so I typically filter the search results to "Library" since this is where the documentation actually exists (otherwise you have to read through a lot of things that are not typically helpful).

    Anyways, you will probably be interested in displaying the data that you retrieve from your database in a control like the DataGridView. The DataGridView has built in scroll bars. Check out the link because it contains documentation on this control's properties, methods, and events along with links to tutorials on how to use it (scroll down on the page) and these tutorials will probably have examples on how to use a database as well.

    -Frinny

    Comment

    • vishal anand
      New Member
      • Sep 2013
      • 7

      #3
      I want to use horizontal scroll bar in windows forms(c# with sql server 2008) because before entering any data to form i want to scroll to see if there are any data of same person(technici an) is there or not. If there are datas of same person then i dont need to enter that data again,if not i can then enter the data.I have coded for horizontal scroll bar below:

      Code:
       SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan16;Integrated Security=true");
                  if (conn.State != ConnectionState.Open)
                  {
                      conn.Open();
                  }
                  SqlCommand cmd = new SqlCommand();
                  cmd.Connection = conn;
                  cmd.CommandType = CommandType.Text;
                  DataTable dt = new DataTable();
                  scrRec.Scroll= dt.Rows.Count + scrRec.Move;
                  lblRecPos.Text = "Record Pos(" + scrRec.Value + 1 + "/" + scrRec.Maximum + 1 + ")";
                  if (dt.Rows.Count == -1)
                  {
                      txtFname.Enabled = false;
                      txtMname.Enabled = false;
                      txtLname.Enabled = false;
                      dtDOB.Enabled = false;
                      cboSex.Enabled = false;
                      txtFname.Text = cmd.Parameters.AddWithValue("technician_first_name", SqlDbType.VarChar).Value.ToString();
                      txtMname.Text = cmd.Parameters.AddWithValue("technician_middle_name", SqlDbType.VarChar).Value.ToString();
                      txtLname.Text = cmd.Parameters.AddWithValue("technician_last_name", SqlDbType.VarChar).Value.ToString();
                      dtDOB.Value = Convert.ToDateTime(cmd.Parameters.AddWithValue("technician_dob", SqlDbType.Date).Value);
                      if ((cmd.Parameters.AddWithValue("technician_type", SqlDbType.Int).Value is DBNull) && (Convert.ToBoolean(cmd.Parameters.AddWithValue("technician_type", SqlDbType.Int).Value == false.GetType())))
                      {
                          cmd.Parameters.AddWithValue("technician_type", cboTechType.SelectedIndex);
                      }
                      else
                      {
                          cboTechType.SelectedIndex = 0;
                      }
                      if (cmd.Parameters.AddWithValue("technician_sex", SqlDbType.VarChar).Value == "M")
                      {
                          cboSex.SelectedIndex = 0;
                      }
                      else
                      {
                          cboSex.SelectedIndex = 1;
                      }
                      conn.Close();
                  }
      [z{Redacted}{{th ird party links, these are blocked by most companies}}]

      Can anyone help me on how to make horizontal scroll bar move through datas entered in database in c# windows forms

      [imgnothumb]http://bytes.com/attachment.php? attachmentid=73 94[/imgnothumb]
      Attached Files
      Last edited by zmbd; Dec 25 '13, 07:02 PM. Reason: [Vishal anand;e image did not show my form.(...)][z{rmvd 3rd prty lnk}{made Bytes atchmnt vsble}{fixed code tags}]

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        If I understand correctly, he wants the Access equivalent of the record selectors/navigation buttons for his C# form.

        Comment

        • vishal anand
          New Member
          • Sep 2013
          • 7

          #5
          Rightly So Sir/Madam. Please help me with horizontal scroll bar coding only. The rest i can manage on my own.

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            Oh Paging?

            I have never actually developed a winforms application before. In WPF I would use a slider control and set it's length/number-of-nodes to the number of records available.

            I do not know if there is a slider equivalent in winforms applications.

            Sorry, hopefully someone else can help you further.

            -Frinny

            Comment

            Working...