|
I would like to add a dropdownlist to my gridview and then selecting an avaliable table from that list. The selected table would show and i could edit it.
I already have a form made with grid view and an option to update and show record in a table. It looks like this:
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
SqlDataAdapter sda;
SqlCommandBuilder scb;
DataTable dt;
public Form1()
{
InitializeComponent();
}
private void button1_click(object sender, EventArgs e)
{
scb = new SqlCommandBuilder(sda);
sda.Update(dt);
MessageBox.Show("Records updated");
}
private void button2_click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=GECKO-PM\\SQLEXPRESS;Initial Catalog=Gecko;Integrated Security=True");
sda = new SqlDataAdapter(@"SELECT ID_vzdrzevanje, Datum, Lokacija, Ime_vrtine, Delo FROM Vzdrzevanje",con);
dt = new DataTable();
sda.Fill(dt);
dataGridView1.DataSource = dt;
}
}
}
Thanks
|
|
|
|
|
I think you want to add the "drop down list" to the form; and NOT the grid.
The code you show has NOTHING to do with that.
So, show something that is relevant if you want help.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Yes im sorry, combobox is added on the form.
Now i've added this code to link combobox so it show all of my tables from SQL database:
String strConnection = "Data Source=GECKO-PM\\SQLEXPRESS;Initial Catalog=Gecko;Integrated Security=True";
SqlConnection con = new SqlConnection(strConnection);
try
{
con.Open();
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.Connection = con;
sqlCmd.CommandType = CommandType.Text;
sqlCmd.CommandText = "Select table_name from information_schema.tables";
SqlDataAdapter sqlDataAdap = new SqlDataAdapter(sqlCmd);
DataTable dtRecord = new DataTable();
sqlDataAdap.Fill(dtRecord);
comboBox1.DataSource = dtRecord;
comboBox1.DisplayMember = "TABLE_NAME";
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Now i would like to link a button with combobox so when i click on button it shows content of selected table in combobox. Or perhaps if the the table is automaticly shown when it is selected in combobox. Any ideas?
|
|
|
|
|
UPDATE:
I have managed to get the chosen table from combobox be shown on the grid view when clicked on a "show table" button. The code on the "show table" button looks like this:
string selected = this.comboBox1.GetItemText(this.comboBox1.SelectedItem);
SqlConnection con = new SqlConnection("Data Source=GECKO-PM\\SQLEXPRESS;Initial Catalog=Gecko;Integrated Security=True");
sda = new SqlDataAdapter(@"SELECT* FROM dbo."+selected,con);
dt = new DataTable();
sda.Fill(dt);
dataGridView1.DataSource = dt;
Be tuned for further improvments or question for help.
|
|
|
|
|
I have one more problem that im stuck on. I would like to add a button, that is in column in every row, to a table that is shown in datagridview. The problem is that this table is drawn from a database, so it si not manualy made, and therefore i dont know how to find that specific column and add a button to every row in that column.
Any help would be appreciated.
|
|
|
|
|
Hello,
As a first time poster, and not a developer (although competent with PowerShell!), I would be grateful for some assistance on the above issue.
I am using VS2013Express to create a windows form based application which will display and eventually print Visio documents, rather than relying on the browser based Visio Viewer. Needless to say this is a very specific requirement, so really don't need anyone telling me to use the MS Visio Viewer!
So far, I can open the Visio document, display it using the AxVisioViewer.dll control. I can even print... to a degree.
The issue is that I can only print currently using a PrintFromScreen method which basically captures the image of the form as displayed on screen and creates a Raster BitMap of it.
I copy the BitMap image to a hidden panel on the form (to remove toolbars etc), then print the contents of the panel. Simple (ish)!
What I want to be able to do is resize (Vector not Raster to retain scale) and centre the image as required to ensure the document prints properly.
This is my first delve into C# and so far it's fun... until you find you can't do something... then it becomes painful!
Any help would be very much appreciated!
Thank you.
Chubbsy.
|
|
|
|
|
chubbsy wrote: What I want to be able to do is resize (Vector not Raster to retain scale) and centre the image as required to ensure the document prints properly. The image you get from the control is a collection of pixels, not a vector-image.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi Eddy,
Thanks for the response.
I agree, the control simply returns a collection of pixels, which is not possible to rescale (not that I've been able to at least).
Are you saying there is no way to properly re-scale the graphic being displayed using the AxVisioViewer ActiveX control?
Is there a different way to output from the control as a scaleable image for printing??
Cheers,
Simon.
|
|
|
|
|
Only by zooming. If the original is low-quality, the printed result will be too.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello,
How can we save .pdf file to a remote server?
Below template is ok at local but I need to save the file at remote host.
I created folder and gave permission at remote host.
Directory.CreateDirectory("d:\\folder\\");
PdfWriter.GetInstance(pdfDosya, new FileStream("d:\\folder\\" + ".pdf", FileMode.Create));
Thanks.
modified 13-Feb-19 21:02pm.
|
|
|
|
|
It depends on how the remote folder is shared (which protocol is used).
Is it within a local network using SMB/CIFS (Windows share) or NFS (Unix)? Or is the remote server accessed using an internet protocol like [S]FTP?
|
|
|
|
|
It's SMB (Windows share)
modified 13-Feb-19 21:02pm.
|
|
|
|
|
Use
//ComputerName/ShareName/[SubDirectory/]FileName when the user account of the local machine has write access to the share on the remote system (e.g. when using domain accounts).
If you have to pass the credentials from your code it is getting more complicated. Search the web for something like "c# access network share with credentials".
|
|
|
|
|
[EDIT] There was a bug in VectorDot, now corrected. Vector2 doing better.
I am trying to compare various operation with normal .NET struct vs SIMD / System.Numerics.Vectors.Vector2 one.
I created this plain C# normal struct and SIMD extensions:
public struct Point2
{
public float X, Y;
<pre>
public Point2(float x, float y)
{
X = x;
Y = y;
}
public float Dot(Point2 p) => X * p.X + Y * p.Y;
public static Point2 operator +(Point2 p, Point2 p2) => new Point2(p.X + p2.X, p.Y + p2.Y);
public static float operator ^(Point2 p, Point2 p2) => p.Cross(p2);
public float Cross(Point2 p2)
{
return X * p2.Y - Y * p2.X;
}
}
public static class VectorExtensions
{
public static float Cross(this Vector2 v, Vector2 v2)
{
return v.X * v2.Y - v.Y * v2.X;
}
}</pre>
And made this text program
class Program
{
static void Main(string[] args)
{
int N = 10_000_000;
<pre>
DoVectorCross(1);
using (new MeasureBlock("Vectors Cross"))
DoVectorCross(N);
DoPointCross(1);
using (new MeasureBlock("Points Cross"))
DoPointCross(N);
DoVectorDot(1);
using (new MeasureBlock("Vectors Dots"))
DoVectorDot(N);
DoPointDot(1);
using (new MeasureBlock("Points Dots"))
DoPointCross(N);
DoVectorAdd(1);
using (new MeasureBlock("Vectors Add"))
DoVectorAdd(N);
DoPointAdd(1);
using (new MeasureBlock("Points Add"))
DoPointAdd(N);
Console.ReadLine();
}
static float DoVectorCross(int N)
{
var v1 = new Vector2(1, 2);
var v2 = new Vector2(2, 3);
float result = 0;
for (int i = 0; i < N; i++)
result += v1.Cross(v2);
return result;
}
static float DoVectorDot(int N)
{
var v1 = new Vector2(1, 2);
var v2 = new Vector2(2, 3);
float result = 0;
for (int i = 0; i < N; i++)
result += Vector2.Dot(v1, v2);
return result;
}
static Vector2 DoVectorAdd(int N)
{
var v1 = new Vector2(1, 2);
var v2 = new Vector2(2, 3);
for (int i = 0; i < N; i++)
v1 += v2;
return v1;
}
static float DoPointCross(int N)
{
var v1 = new Point2(1, 2);
var v2 = new Point2(2, 3);
float result = 0;
for (int i = 0; i < N; i++)
result += v1.Cross(v2);
return result;
}
static float DoPointDot(int N)
{
var v1 = new Point2(1, 2);
var v2 = new Point2(2, 3);
float result = 0;
for (int i = 0; i < N; i++)
result += v1.Dot(v2);
return result;
}
static Point2 DoPointAdd(int N)
{
var v1 = new Point2(1, 2);
var v2 = new Point2(2, 3);
for (int i = 0; i < N; i++)
v1 += v2;
return v1;
}
}</pre>
I get the following measurement for each compile target (x86, x64/ AnyCPU):
x64
Vectors Cross took 24ms.
Points Cross took 17ms.
Vectors Dots took 16ms.
Points Dots took 21ms.
Vectors Add took 35ms.
Points Add took 109ms.
x86
Vectors Cross took 41ms.
Points Cross took 38ms.
Vectors Dots took 49ms.
Points Dots took 40ms.
Vectors Add took 38ms.
Points Add took 47ms.
AnyCPU
Vectors Cross took 40ms.
Points Cross took 39ms.
Vectors Dots took 43ms.
Points Dots took 39ms.
Vectors Add took 49ms.
Points Add took 58ms.
Vector2 has now similar performance to Point2 , except when compiled for x64, Dot() is 25% faster and Add() is 3 times faster.
Custom Cross() operations is slower though.. How do I write efficient Cross operation?
modified 29-Apr-18 23:10pm.
|
|
|
|
|
I'm not a C# programmer and have only basic knowledge. So this might not be correct.
I guess that your Vector2 Cross function does not use any SIMD instructions or is at least not parallelised.
Have a look at the Vector2 source (Vector2_Intrinsics.cs[^]):
using System.Runtime.CompilerServices;
namespace System.Numerics
{
[Intrinsic]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Dot(Vector2 value1, Vector2 value2)
{
return value1.X * value2.X +
value1.Y * value2.Y;
}
} You might try to implement Cross similar.
|
|
|
|
|
This was actually a good idea!
Except, sadly, [Intrinsic] is not available to us, non MS programmer. I fear this might not just be possible to implement 3rd SIMD extension method. How sad....
|
|
|
|
|
Super Lloyd wrote: Except, sadly, [Intrinsic] is not available to us, non MS programmer So that is the reason why there is not much documentation about it.
But it seems to be the option that enables usage of processor specific instructions like SIMD.
|
|
|
|
|
Is it worth it?
I am writing a lib that do shape operation (shape being like polygon, just with bezier curve for contour instead of lines)
I have a lot of custom Math code, including custom Point2D, Vecto2D and Matrix3x2 and today.. I just saw that System.Numerics is such a library with such types but hardware accelerated (SIMD) maths.
Since my lib is quite performance intensive I wonder if it is worth rewriting?
Any link on performance guide and comparison with Numerics.Vectors?
I found some post on the internet where people had bad experience an unexpectedly worst performance with it.....
modified 29-Apr-18 20:59pm.
|
|
|
|
|
Hi All,
I am working on a project using c# .net and its related to connecting to device and streaming the information over the network . We are using RTSP protocol for connecting to that device. We have developed code using media-player-vlc, while testing the code we have observed a strange behavior , where we are able to play local file and public streaming url. where as when we try with our customer url. its giving the below error. the same url when we try to play using VLC media player its working fine.
[0b7204c0] live555 demux error: Failed to connect with rtsp:
[0b7204c0] live555 demux error: TCP rollover failed, aborting
Could any one please update me on this.
|
|
|
|
|
That is most probably a problem with the network configuration on a router or the firewall on the server that blocks traffic from/to specific IPs and/or ports (assuming that the service at your customer URL is up).
Ensure first that the service is up testing it locally or from a client in the same (local) network segment. Once that is working check the configuration of the router that connects the server to the internet. If that provides logs, check those too. Ensure that the IP and port from the URL are allowed for UDP.
|
|
|
|
|
Hi Jochen ,
thanks for the quick response, I agree with you and tried by playing same url in VLC media player. If this is because of network issue, the same url should not work through VLC Media Player.
But its working. Not sure , whether is there anything which is blocking in libVLC.dll.
When I try to debug into code.. i found the following code is causing issue.
https://github.com/Tilka/vlc/blob/master/modules/demux/live555.cpp
else if( !p_sys->b_multicast && !p_sys->b_paused &&
p_sys->b_no_data && ( p_sys->i_no_data_ti > 34 ) )
{
bool b_rtsp_tcp = var_GetBool( p_demux, "rtsp-tcp" ) ||
var_GetBool( p_demux, "rtsp-http" );
if( !b_rtsp_tcp && p_sys->rtsp && p_sys->ms )
{
msg_Warn( p_demux, "no data received in 10s. Switching to TCP" );
if( RollOverTcp( p_demux ) )
{
msg_Err( p_demux, "TCP rollover failed, aborting" );
return 0;
}
return 1;
}
msg_Err( p_demux, "no data received in 10s, aborting" );
return 0;
}
Do we need to change anything to overcome this?
Best Regards
|
|
|
|
|
If it is working with the VLC media player it is not a general network issue.
But I think you are debugging at the wrong location. The above code (and the error message) tells you there was a failure to connect using UDP and a fallback to TCP has been initiated which is also failing.
I'm sorry that I can't help more. I even think that debugging will not help much with such connection timeout errors. All I can suggest is asking at the GitHub project site.
|
|
|
|
|
Thanks Jochen for your time and effort
|
|
|
|
|
Hi Jochen,
After lot of analysis found the root cause of the issue but don't know how to fix this issue.
In VLC Media player , its working , because , we explicitly set Live 555 Stream transport to RTP Over RTSP(TCP), due to this the streaming is working and able to view the video.
But same way not sure how to set this option to below code
IMedia media = m_factory.CreateMedia<imedia>(rtspAddress);
//media.AddOptions(new List<string>() {output });
//media.AddOptions(mediaOptions);
m_player.WindowHandle = p.Handle;
m_player.Open(media);
//media.Parse(true);
m_player.Play();
could you please suggest us on this.
thanks in advance.
|
|
|
|
|
So we are working on a project that involves creating a simple mobile application using Xaml and C#. We are done with the design but we are having difficulties programming the calculator.
Here in the UAE we have 5% Tax on some goods, so we want the users to be able to enter the items price to see how much it will be after adding the 5% tax and the amount added to it.
For example, a user wants to be a 250 AED item and used the App to see how much it would cost with taxes so once they input the item price and hit the calculate button they will see the price with taxes and how much was added to the original price.
FYI: I am a beginner at this and just taking a course with C# fundamentals I really could use someones help with this.
Regards
|
|
|
|