|
hi.... i have made two fields in SQL server 2005 named DistrictId smallint and DistrictName varchar(100).In a web application (language C#) i have made a form in which i have made a text box in which user will enter the name of the district which he want to modify.i want a code for the purpose that user will enter the name of district and when he click on the button named MODIFY the district name will be modified.Please help me as soon as possible...........
|
|
|
|
|
SqlParameter[] myparm = new SqlParameter[2];
myparm[0] = new SqlParameter("@DistrictNewName", this.txtDistricNewName.Text);
myparm[1] = new SqlParameter("@DistrictName", this.txtDistricName.Text);
String SqlQuery = "UPDATE TableName SET DistrictName = @DistrictNewName WHERE DistrictName = DistrictName";
This should get you started.
|
|
|
|
|
how can i write the code for auto completion of sentence or word in c# .net?
|
|
|
|
|
what you mean by auto completion
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
hi everyone
I want to connect a comport of other computer on network.But i not connect.
How do I connect?
|
|
|
|
|
|
I am a beginner
Iwant to know what is dll file and how to create a setup file
|
|
|
|
|
Hi,
DLL - Dynamic Link Library
DLL refers to a type of file that is stored either locally or remotely and is a collection of commands and/or data which can be shared by different programs on the same platform.
Typical DLL files contain commands and/or data that are common to a certain task, for instance Windows has many DLL files built-in which other programs access and utilise.
For more information on this please refer to the following linke:
What is dll File?[^]
Following are the steps to create a setup file using VB.Net
1) Select the setup and deployment projects when clicking the new project in the vb.net.
2) Select the setup project and enter the name in the text box .
3) The setup1 file will be created.
4) Add project output for the setup1.
5) Create shortcut for the appliction folder and user's desktop.
6) Change the configuration into release from the configuration manager.
7) And the build the setup.
Hope this helps
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
will there be any change with C#
because i am doing every thing on C#
|
|
|
|
|
It should be the same for a C# app.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Hi kiranreddy123
I understand that you want to learn and all that, but before you can start asking someone what is what , you have to make a research your self.You see, you cannot be a Good Programmer if you dont research. try to buy a Book and there are some E-books that you can get for free that i can share too. but please Google first before you post because if you google your question, you will find a lot of asnwers.
Hope this Helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hi,
I want to create a Windows Media Services Publising Point using C#, with only RTSP stream.
I have the file path, and publising point name input by user.
Also how can we chaek if the Publising point is exisiting or not, and also to check that is a certain publishing point is started or not.
Plzzzz Help.
Thanks.
Deepak Surana
|
|
|
|
|
Did you ever figure this out? I need to do the same thing, and it's been a pain.
Thanks....
|
|
|
|
|
Hi all,
Can i use override void OnPaintBackground in custom user control?My purpose to use this method in custom user control is because i will draw the base line (grid) as image in the drawing area at the initiate state, but after that, i don't want to repaint again the background(image) when i draw some line on it. Thus, i need to override the OnPaintBackground method and disable it to fulfill my purpose. I can done it in Component,but how about in custom user control?
Any tips are welcome.
regards
cocoonwls
|
|
|
|
|
Hi,
you can override OnPaintBackground, I haven't have any problem with that so far. If you want to draw over default background, be sure to call base.OnPaintBackground as a first thing in your override method. If you want to draw your background completely by yourself, don't call base.OnPaintBackground at all.
hope this helps
|
|
|
|
|
hi Michal Martinka,
Thanks for your hlep.i will try it out
|
|
|
|
|
Hi, i'm new in this forum.
I am currently developing a Pocket Application using C# & SQL CE. Now, everything was working fine until just now. When I do any type of operations in the database (insert, update & delete) running the application in the device everything goes right, no errors. But When I check the database, no changes has been made. It seems that everything is working but I do not know if I'm missing something. I didn't noticed this until i was testing my RDA functions, when i realized that the tables didn't have any data of the SQL Server, any idea of how to solve this?
this class creates connections to the SQL CE database.
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlServerCe;
using System.Data.SqlClient;
using System.Windows;
using System.IO;
using CAPocket.Clases;
namespace CAPocket.Clases
{
class Data
{
String cadenaCon;
public Data()
{
cadenaCon = @"Data Source =\Program Files\CAPocket\Sistema.sdf;SSCE:Database Password='pam653045';";
}
public SqlCeConnection GetConnection()
{
SqlCeConnection con = new SqlCeConnection(cadenaCon);
try
{
con.Open();
return con;
}
catch (SqlCeException ex)
{
return null;
}
}
public SqlCeDataAdapter getAdapter(String s_sql)
{
SqlCeDataAdapter adp;
try
{
adp = new SqlCeDataAdapter(s_sql, cadenaCon);
return adp;
}
catch (SqlCeException ex)
{ return null; }
}
}
}
This code block of a class allows the administrator to add, delete or get all the users registered in the application:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlServerCe;
using System.Data.SqlClient;
using System.Windows;
using System.IO;
using System.Data;
using CAPocket.Clases;
namespace CAPocket
{
class GestionUsuarios
{
public GestionUsuarios()
{
}
Data cex;
SqlCeConnection cnn;
SqlCeCommand cmd;
public bool NuevoUsuario(String user, String pass, String tipo)
{
cex = new Data();
cnn = cex.GetConnection();
if (cnn != null)
{
String sql = "insert into Usuarios values ('" + user + "','" + pass + "', '" + tipo + "')";
cmd = new SqlCeCommand(sql, cnn);
try
{
cmd.ExecuteNonQuery();
return true;
}
catch (SqlCeException ex)
{ return false; }
finally
{ cnn.Close(); }
}
else
{ return false; }
}
public bool Existe(String user, String pass)
{
cex = new Data();
cnn = cex.GetConnection();
String sql = "select * from Usuarios where Usuario='" + user + "'";
if (cnn != null)
{
cmd = new SqlCeCommand(sql, cnn);
try
{
SqlCeDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
return true;
}
else
{
return false;
}
}
catch(SqlCeException ex)
{ return false; }
finally
{ cnn.Close(); }
}
else
{ return false; }
}
public DataSet getAllUsers()
{
DataSet ds = new DataSet();
cex = new Data();
SqlCeDataAdapter adp = cex.getAdapter("Select Usuario, TipoUsuario from Usuarios order by TipoUsuario");
adp.Fill(ds, "Usuarios");
return ds;
}
public bool EliminarUsuario(String user)
{
cex = new Data();
cnn = cex.GetConnection();
String sql = "delete from Usuarios where Usuario='" + user + "'";
if (cnn != null)
{
cmd = new SqlCeCommand(sql, cnn);
try
{
cmd.ExecuteNonQuery();
return true;
}
catch (SqlCeException ex)
{ return false; }
finally
{ cnn.Close(); }
}
else { return false; }
}
}
}
the next code is from the form where you add, delete and show all the users.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
using System.Data.SqlClient;
using System.Windows;
using System.IO;
using CAPocket.Clases;
namespace CAPocket
{
public partial class frmUsuarios : Form
{
public frmUsuarios()
{
InitializeComponent();
}
public DataSet dset;
GestionUsuarios gu;
public void RefreshGrid()
{
gu = new GestionUsuarios();
dset = new DataSet();
dset.Clear();
dset = gu.getAllUsers();
dataGrid1.DataSource = dset.Tables["Usuarios"];
dataGrid1.TableStyles.Clear();
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = "Usuarios";
DataGridColumnStyle cUsuario = new DataGridTextBoxColumn();
cUsuario.HeaderText = "Usuario";
cUsuario.MappingName = "Usuario";
cUsuario.Width = 75;
ts.GridColumnStyles.Add(cUsuario);
DataGridColumnStyle cTipoUsuario = new DataGridTextBoxColumn();
cTipoUsuario.HeaderText = "Tipo de Usuario";
cTipoUsuario.MappingName = "TipoUsuario";
cTipoUsuario.Width = 100;
ts.GridColumnStyles.Add(cTipoUsuario);
dataGrid1.TableStyles.Add(ts);
}
private void frmUsuarios_Load(object sender, EventArgs e)
{
RefreshGrid();
}
private void btAgregar_Click(object sender, EventArgs e)
{
GestionUsuarios gu = new GestionUsuarios();
bool resultado = gu.Existe(txtUsuario.Text, txtPassword.Text);
if (resultado == false)
{
if (radioButton1.Checked == true)
{ resultado = gu.NuevoUsuario(txtUsuario.Text, txtPassword.Text, "Usuario"); }
if (radioButton2.Checked == true)
{ resultado = gu.NuevoUsuario(txtUsuario.Text, txtPassword.Text,"Administrador"); }
if (resultado == true)
{
MessageBox.Show("Usuario agregado exitosamente", "Resultados");
RefreshGrid();
}
else
{ MessageBox.Show("Error al guardar","Errores"); }
}
else
{
MessageBox.Show("El usuario ya existe","Errores");
}
txtUsuario.Text = "";
txtPassword.Text = "";
}
private void datagrid1_Click(object sender, EventArgs e)
{
dataGrid1.Select(dataGrid1.CurrentRowIndex);
textBox1.Text = dataGrid1[dataGrid1.CurrentRowIndex, 0].ToString();
}
private void dataGrid1_CurrentCellChanged(object sender, EventArgs e)
{
dataGrid1.Select(dataGrid1.CurrentRowIndex);
textBox1.Text = dataGrid1[dataGrid1.CurrentRowIndex, 0].ToString();
}
private void btEliminar_Click(object sender, EventArgs e)
{
gu = new GestionUsuarios();
bool resultado = gu.EliminarUsuario(textBox1.Text);
if (resultado == true)
{
MessageBox.Show("Usuario eliminado", "Resultados");
RefreshGrid();
}
else
{ MessageBox.Show("Error al eliminar", "Error"); }
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Hope anyone can help me!
|
|
|
|
|
Put break points and step into to the code.
three.leaf wrote: "select * from Usuarios where Usuario='" + user + "'";
three.leaf wrote: "insert into Usuarios values ('" + user + "','" + pass + "', '" + tipo + "')";
Ahh , SQL injection. Read this[^]
|
|
|
|
|
I put the break points, and step into the code but still, not working. While I run it in the emulator, it adds the data to the mobile database, but after i stop the debugging and restart the application, the data is lost.
Any other idea?
|
|
|
|
|
I created a client-server application. So far I created 3 Projects from visual studio C#.. First project is the Server project, second project is the Client Project, and the Third Project is the connector project. The connector project is responsible for linking the client and the server together. Here's the problem, the connector project produces a DLL file when compiled which will be imported into the client and into the server so that they can communicate with each other. So this time after importing the DLL file to the client project and server project, I compiled them and beside the produced executable file of the 2 projects you can find the DLL file that has been imported. The problem is without the DLL(beside the executable) the program doesn't work. What I was expecting is that during the compilation of the 2 projects(client and server) the DLL is somehow integrated on the executable file and I could just copy the EXE file and run it on any computer. Do you have any idea how I can do this?
|
|
|
|
|
You can't. You obvioulsy misunderstood what a dll is. It's a seperate file. You can write a ton of code to fail gracefully, but the point of a dll is to be seperate. If you want it all in the exe, move the code into the main project.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
|
Hello,
I have a console application the runs every few minutes and processes some files.
I am using the timer to do that.
However, I want the console window to disappear when my code is done processing all the files, then to reappear after the specific time has elapsed.
I dont know how to do this.
Thanks.
|
|
|
|
|
The simple way is to run it via a Scheduled Task instead.
|
|
|
|
|
Thanks PIEBALD. I think thats a great idea.
|
|
|
|