Hi all, I resolved it myself, change the DataSet ds = new DataSet(); int li_rows = adp.Fill(ds, "myds"); I used a datatable and changed the retrieval to adp.fille(dt) ; objRpt.SetDataSource(dt); and it works any ways, thanks everyone.
User 3950922
Posts
-
Crystal reports with C#, Displays a error message. -
Crystal reports with C#, Displays a error message.Hi , I am trying to display a crystal report using the crystal report viewer in vs 2008,and it does not display instead it gives a database login screen. This is the code which I am using . ================================================================== CrystalReport1 objRpt; //Usermaster objRpt; objRpt = new CrystalReport1(); string connstr = "Persist Security Info=False;userid=btssys; password=xx23;database=bts;server=xxxx"; MySqlConnection mc = new MySqlConnection(connstr); try { mc.Open(); string sql = "select userid, usergiven,userfamily,status,expiry,created,created_by from user_master"; MySqlCommand cmd = new MySqlCommand(sql, mc); MySqlDataAdapter adp = new MySqlDataAdapter(sql, mc); //new MySqlDataAdapter( DataSet ds = new DataSet(); int li_rows = adp.Fill(ds, "myds"); if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show("No data Found", "CrystalReportWithmysql"); return; } // Setting data source of our report object objRpt.SetDataSource(ds); // Binding the crystalReportViewer with our report object. crystalReportViewer1.ReportSource = objRpt; ================================================================================ If I debug I can find that the ds is retrieving the rows. But nothing comes up on the crystal report viewer.It displays a database login screen instead with server name as myds. Is this something to do with Mysql or something wrong with VS 2008 or crystal report coding. Thanks
-
How to get the application data folder for each user ?Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
-
How to get the application data folder for each user ?Hi I am writing a small program , I need to find the application data folder which exists in c:\documents and settings folder. I need to know the exact path, if the user has installed the windows in d:\ then it should look at d:\. Even if I could know the windows installation drive then I think it would help ? I got some code in VB but i cannot use it in csharp . Any suggestions would be appreciated. //************************************************************ Public Function GetTheWindowsDirectory() As String Dim strWindowsDir As String ' Variable to return the path of Windows Directory Dim lngWindowsDirLength As Long ' Variable to return the the lenght of the path strWindowsDir = Space(250) ' Initilize the buffer to receive the string lngWindowsDirLength = GetWindowsDirectory(strWindowsDir, 250) ' Read the path of 'the windows directory strWindowsDir = Left(strWindowsDir, lngWindowsDirLength) ' Extract the windows 'path from the buffer GetTheWindowsDirectory = strWindowsDir //********************************************* The above is the code for vb.net Thanks
-
Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.Hi there, When I use the following code below I get and error called , "concurrency violation" and the database is not updated. I am able to connect and retrieve data. but I cannot update the data from the datatable of dataset. I am new to datagridview and datasets. I am using Mysql 5.0 and Mysql connector .NET 5.1.2 I read many articles on updating the dataset and almost tried everything , but It does not work, I can update to Mysql database using update commands. But I want to use Dataset or dataadapter update to make it more simpler. public partial class Form1 : Form { DataSet ds = new DataSet(); MySqlDataAdapter da; DataTable dt = new DataTable(); string tabname; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { CreateMySqlCommand(); } // Connecting to db and filling the datagridview with data. public void CreateMySqlCommand() { MySqlConnection myConnection = new MySqlConnection("Persist Security Info=False;userid=root;password=XXXX;database=test;server=terrain"); myConnection.Open(); MySqlTransaction myTrans = myConnection.BeginTransaction(); string mySelectQuery = "SELECT * FROM patient_master"; MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection,myTrans); da = new MySqlDataAdapter(mySelectQuery ,myConnection) ; MySqlCommandBuilder cmdBldr = new MySqlCommandBuilder(da); da.Fill(ds); dt = ds.Tables[0]; DataRow row; row = dt.Rows[0]; int lirow = dt.Rows.Count; string mrno = row["MRNO"].ToString(); string patname = row["GIVEN_NAME"].ToString(); dataGridView1.DataSource = ds; dataGridView1.DataMember = ds.Tables[0].ToString(); tabname = dt.TableName; int y = 0; foreach (DataGridViewRow ro in dataGridView1.Rows) { if (y % 2 == 0) ro.DefaultCellStyle.BackColor = Color.Red; y++; } } // code on the button to update the datadapter private void button1_Click(object sender, EventArgs e) { da.Update(ds, tabname); } } }
-
Datagridview changing the row backcolor based on value of coloum in the same grid viewYes , putting the code on the cell formatting event of the datagridview worked, I mentioned that I was using a user control. The data grid was on the User control. If not a user control then the other stuff works fine. thanks
-
Datagridview changing the row backcolor based on value of coloum in the same grid viewHi Pedram , I tried this as well it does not work, first I selected all rows which meet the specified condition This is just to show the selection, Its alternate rows here but in real scenario its any random row. int yyy = 0; foreach (DataGridViewRow rowss in dataGridView1.Rows) { if (yyy % 2 == 0) { rowss.Selected = true; } else { } yyy++; } , then I used your or each statement but still I get the same results. There is no color on the datagridview. This Datagridview is placed on a user Object and It is added on a form at the run time.Does it make any difference ? Regards Omer
-
Datagridview changing the row backcolor based on value of coloum in the same grid viewHi all, I have been trying to change the backcolor of specific rows depending on a condition,but when the condition is met the entire grid color changes. I already tried this and many more like this but none of them work, DataGridViewCellStyle style2 = new dataGridViewCellStyle() style2.BackColor = Color.Red; dataGridView1.RowsDefaultCellStyle.BackColor = Color.Red; There is something which I am doing wrong. Please help me to fix this.
-
Hi , I help needed in events and graphicsI am using csharp to create a user control for creating bar graphs, The user control will use rectangles as bars, (drawn using gdi+). I am adding this user control to a form, Now when i focus each bar in the user control instance on the form , it should raise a mouse hover event. I am unable to identify when the mouse is over the rectangle. I do not want to calculate the position of mouse and then check what is drawn at what pixel and then raise the event. I want some ideas on how to identify each bar or rectangle individually from the main form. Is it possible or I am just imagining ? Hope you guys understand my problem ?
-
Creating Instance of button at run time.Thanks Lisan I'll get some good books but until then this works. int left = 0; int space = 1; //pix int nbButtons = 5; for (int i = 0; i < nbButtons; i++) { GlassButton gb = new GlassButton(); gb.Name = i.ToString(); gb.Text = i.ToString(); gb.Left = left; gb.Location = new Point(20 + (i*5) , 10 + (i *5) ); this.Controls.Add(gb); //gb is a user control left += gb.Left + gb.Width + space; } Thanks again
-
Creating Instance of button at run time.Hi Greeg, If I had to create 100 buttons ,I do not want to write this code 100 times. I want something which is like cloning or creating Instances, for a user object button.Its not clear to me how we can do it in csharp.
-
Creating Instance of button at run time.Dear All Hi,I am new to csharp, I want to create a Bar Graph without using the graphics class, I want to use a button and adjust its size so that it looks like a bar.I will populate the properties of the buttons (size,color,position) at the run time. I need to create button instances at run time, I tried creating user objects of the button, but still I am unable to create many buttons at runtime. Any help or ideas will be appreciated . Thanks