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
  1. Home
  2. General Programming
  3. C#
  4. Could use some help please.

Could use some help please.

Scheduled Pinned Locked Moved C#
databasehelpcsharpgraphics
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pestman
    wrote on last edited by
    #1

    Ok ill start by saying I am new to c# what i am trying to do is basicly access a ultralite db it has a table named Names(name,chan,freq,mpchan) I want to populate a combox with name field than have 3 text fields populate with the appropriate data for the name selection. Here is what i got so far

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Text;
    using System.Windows.Forms;
    using iAnywhere.Data.UltraLite;
    using System.Collections;
    
    namespace ChannMap
    {
        public partial class Form1 : Form
        {
            private string strChan;
            private string strFreq;
            private string strName;
            private string strMapChan;
            private string strTemp;
            private string [] strArraylist=new string [1000];
            static int i = 0; //index for strArraylist
            private ULConnection ConnUL = new ULConnection();
            private ULDataAdapter myDataAdapter = new ULDataAdapter();
            private void Form1_Load(object sender, System.EventArgs e)
            {
                fnGetConnectedToDatabase();
            }
            public Form1()
            {
                InitializeComponent();
                
            }
            private void fnGetConnectedToDatabase()
            {
                try
                {
                    String dbf = "\\Program Files\\ChannMap\\ChannMap.udb";
    
                    if (System.IO.File.Exists(dbf))
                    {
                        ConnUL.ConnectionString = "dbf=" + dbf + ";cache_size=1M";
                        if (ConnUL.State != ConnectionState.Open)
                        {
                            ConnUL.Open();
                        }
                        ConnUL.DatabaseID = 1000;
                    }
                    else
                    {
                        MessageBox.Show("Database is not available", "Error");
                        Application.Exit();
                    }
                }
                catch (System.Exception t)
                {
                    MessageBox.Show(t.Message, "Connection failed");
                    return;
                }
                string sqlStr = "SELECT * FROM Names;";
                			myDataAdapter = new ULDataAdapter(sqlStr,ConnUL);
    
    			//Instantiate a DataSet
    			DataSet myDataset = new DataSet();
    			
    			// Populate the data table "Names"
    			myDataset.Clear();
    			myDataAdapter.Fill(myDataset,"Names");		
    			
    			foreach (DataRow myRow in myDataset.Tables["Names"].Rows)
    			{
    				strChan =(string) myRow["chan"];
    
    K 1 Reply Last reply
    0
    • P pestman

      Ok ill start by saying I am new to c# what i am trying to do is basicly access a ultralite db it has a table named Names(name,chan,freq,mpchan) I want to populate a combox with name field than have 3 text fields populate with the appropriate data for the name selection. Here is what i got so far

      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.IO;
      using System.Text;
      using System.Windows.Forms;
      using iAnywhere.Data.UltraLite;
      using System.Collections;
      
      namespace ChannMap
      {
          public partial class Form1 : Form
          {
              private string strChan;
              private string strFreq;
              private string strName;
              private string strMapChan;
              private string strTemp;
              private string [] strArraylist=new string [1000];
              static int i = 0; //index for strArraylist
              private ULConnection ConnUL = new ULConnection();
              private ULDataAdapter myDataAdapter = new ULDataAdapter();
              private void Form1_Load(object sender, System.EventArgs e)
              {
                  fnGetConnectedToDatabase();
              }
              public Form1()
              {
                  InitializeComponent();
                  
              }
              private void fnGetConnectedToDatabase()
              {
                  try
                  {
                      String dbf = "\\Program Files\\ChannMap\\ChannMap.udb";
      
                      if (System.IO.File.Exists(dbf))
                      {
                          ConnUL.ConnectionString = "dbf=" + dbf + ";cache_size=1M";
                          if (ConnUL.State != ConnectionState.Open)
                          {
                              ConnUL.Open();
                          }
                          ConnUL.DatabaseID = 1000;
                      }
                      else
                      {
                          MessageBox.Show("Database is not available", "Error");
                          Application.Exit();
                      }
                  }
                  catch (System.Exception t)
                  {
                      MessageBox.Show(t.Message, "Connection failed");
                      return;
                  }
                  string sqlStr = "SELECT * FROM Names;";
                  			myDataAdapter = new ULDataAdapter(sqlStr,ConnUL);
      
      			//Instantiate a DataSet
      			DataSet myDataset = new DataSet();
      			
      			// Populate the data table "Names"
      			myDataset.Clear();
      			myDataAdapter.Fill(myDataset,"Names");		
      			
      			foreach (DataRow myRow in myDataset.Tables["Names"].Rows)
      			{
      				strChan =(string) myRow["chan"];
      
      K Offline
      K Offline
      Kubajzz
      wrote on last edited by
      #2

      I did't read the whole code, but I can see a problem in the way you use the String.Split method.

      splitstr = strArraylist[this.comboChanName.SelectedIndex].Split(delimstr, 4);

      This won't compile because it is not a valid overload. You should use delimeter instead of delimstr as the first parameter... See the complete list of String.Split overloads.

      P 1 Reply Last reply
      0
      • K Kubajzz

        I did't read the whole code, but I can see a problem in the way you use the String.Split method.

        splitstr = strArraylist[this.comboChanName.SelectedIndex].Split(delimstr, 4);

        This won't compile because it is not a valid overload. You should use delimeter instead of delimstr as the first parameter... See the complete list of String.Split overloads.

        P Offline
        P Offline
        pestman
        wrote on last edited by
        #3

        Didnt seem to have an effect when changed

        K 1 Reply Last reply
        0
        • P pestman

          Didnt seem to have an effect when changed

          K Offline
          K Offline
          Kubajzz
          wrote on last edited by
          #4

          Ok. I will try to ignore the fact that you provided way too much code that seems very cryptic and unreadable, while only about 10 lines are related to the error... I will ignore the fact that most of the infrotmation you provided with your code is absolutely useless and irrelevant. I will ignore the fact that the title of your first post is the second worst possible title (the first one being "PLZ HELP URGNT"). And I will also try to ignore the fact that your last post didn't contain that mysterious word starting with "tha" and ending with "nks"... If my previous advice didn't help, there is not much more I can do for you. The best help I can give you is: Read the compiler error carefully. Locate the problem in your code. Check everything on that line, see what parameters are required for each method... And then make sure that the parameters you are passing match the required type. With intellisense and all the support provided by Visual Studio (or whatever tool you use) it should not take more than 23.7865039 seconds to locate and fix such a simple error like a type mismatch... even if you are a beginner!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

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