|
hello.
change the datatype in database for index to either something bigger integer value,
or string, and then perform conversion form string to int and vice versa at front-end.
the first approach is more convenient.
good luck.
|
|
|
|
|
Hi, How you can store string data into an int column, i dint get it. The vice-cersa can happen but not this.
Moreover u shud alwayz make a standard to use parametrised query and not concatenate it or u will introduce a vulnerability to SQL injection attack.
parametrised query is formed like this.
SqlCommand sql_cmd = new SqlCommand("insert into Info values(@id,@name,@age)");
sql_cmd.Parameters.Add("@id", SqlDbType.Int);
sql_cmd.Parameters.Add("@name", SqlDbType.NVarChar);
sql_cmd.Parameters.Add("@age", SqlDbType.Int);
sql_cmd.Parameters["@id"].Value = int.Parse(textBox1.Text);
sql_cmd.Parameters["@name"].Value = "Aman";
sql_cmd.Parameters["@age"].Value = 23;
sql_cmd.ExecuteNonQuery();
try, re-typing the column to varchar if it does not necessarily need to store int data, this should solve the problem or else try parsing your string data to int like int.parse(<string value="">);
|
|
|
|
|
Hi All,
I have one web project which was working fine but after i enable SSL, i could open the project by having the error below:
"The web server reported the following error when attempting to create or open the web project located at the following URL : Http://localhost/download.aspx', HTTP/1.1 403 Access Forbidden"
Another clue that i have is the the cert name that someone created is called "PENEDITEST.pen.apac.com", but my testing server name is "PENEDITEST01", i am not sure whether is it because of this reason that making the error pop up.
Kindly Advice.
Regards,
Lygine
|
|
|
|
|
i send 6 + 1 (6 variables and one starting byte)data from microcontroller to c#.first character is ZERO .and it means next value is first value.another meaning zero will be starting byte.how can i latch zero than save other variables to my array?
|
|
|
|
|
What are these 6 variables you're talking about? Ints of 4 bytes? Ints of 2 bytes? Just bytes?
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
each of data is just one byte.(between 0-255)
|
|
|
|
|
OK, now how do you get this data into your application? Do you have a method that gets passed these 7 bytes as an array? Are you reading it as a stream? I'm trying to help, but you're not providing enough information.
Unfortunately, I don't have access to webmail at work, so I can't see the reply notifications
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
All of my microcontroller codes :
#include "C:\Documents and Settings\yasin\Desktop\yeni\deneme3.h"
#include <16F877.h>
#device adc=8
#use delay(clock=20000000)
#fuses NOWDT,HS, NOPUT, NOPROTECT, BROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
void main()
{
int8 value1,value2,value3,value4,value5,value6;
int8 start;
value1=1;
value2=2;
value3=3;
value4=4;
value5=5;
value6=6;
start=0;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
for(;;)
{
delay_ms(10);
putc(start);
putc(value1);
putc(value2);
putc(value3);
putc(value4);
putc(value5);
putc(value6);
}
C# codes:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
namespace serial
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
serialPort1.DataReceived += new SerialDataReceivedEventHandler(this.serialPort1_DataReceived);
if (serialPort1.IsOpen)
serialPort1.Close();
serialPort1.ReceivedBytesThreshold = 1;
serialPort1.DataBits = 8;
serialPort1.Parity = System.IO.Ports.Parity.None;
serialPort1.StopBits = System.IO.Ports.StopBits.One;
serialPort1.BaudRate = 9600;
serialPort1.PortName = "COM4";
serialPort1.Open();
}
public delegate void updatetexboxes();
byte[] received ={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
int i=0;
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
serialPort1.Read(received, i, 1);
//i dont know which codes can be written here!!!!
//than i ll update my variables.
this.Invoke(new updatetexboxes(this.updatetext));
}
private void updatetext()
{
textBox1.Text = received[1].ToString();
textBox2.Text = received[2].ToString();
textBox3.Text = received[3].ToString();
textBox4.Text = received[4].ToString();
textBox5.Text = received[5].ToString();
textBox6.Text = received[6].ToString();
}
}
}
|
|
|
|
|
You've only given some of the C# code. Look at a file called Form1.Designer.cs, or something similar. Here are some tips to get you started:
1. I don't see a definition for serialPort1. What type is it?
2. What does serialPort1.Read() return, if anything?
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
i use serialport component from toolbox.i get datas.cause i use breakpoints so i see my variables content.
|
|
|
|
|
Hi,
i want to pick up a file or correctly if i say, if there exist a text file then i want to read the contents of that file then want to send those content to another destination.
the software on which i am working is like Message sender/receiver, so i have to send that content as message to other destination.
so, is there any way by which i can pick a file, i m using c#.net as plateform.
And its my humble request, plz clarify in detail as i m not that good in programming and got confused easily. As i m still in phase of learning.
|
|
|
|
|
|
Hi humdumof, C#.NET provides a namespace System.IO which can be used for handling files and a class StreamReader and StreamWriter which can be used to read from or write to a file. As shown below
<br />
string path = @"D:\file.txt";<br />
<br />
if (File.Exists(path))<br />
{<br />
using (StreamReader sr = new StreamReader(path))<br />
{<br />
textBox1.Text = sr.ReadToEnd();<br />
sr.Close();<br />
}<br />
using (StreamWriter sw = new StreamWriter(@"D:\newfile.txt"))<br />
{<br />
sw.WriteLine(textBox1.Text);<br />
sw.Close();<br />
}<br />
}<br />
else<br />
{<br />
MessageBox.Show("File does not exist.");<br />
}<br />
This code first checks for the existence of the file and if present, it reads the content to a textbox and then copies/send the same data to other destination file, else, reads an error message. Hope it helps you.
|
|
|
|
|
i want add one property to my control.when i put mouse in that property i want to open one more window.same like datagrid table styles.How can i make a property like that?....................
|
|
|
|
|
Go and buy a book on winforms basics, or google and read up.
|
|
|
|
|
Please give code for checking the valid username and password from database
|
|
|
|
|
|
try {
SqlConnection con = new SqlConnection("connectionstring");
string sqlQuery = "select user,pwd from Login where user= ' " + this.TextBox1.Text + " ' and pwd=' " + this.TextBox2.Text + " ' ";
con.Open();
SqlCommand com = new SqlCommand(sqlQuery, con);
int results = com.ExecuteScalar;
if (results == 1)
{
return true;
}
else
{
return false;
}
con.Close();
com.Dispose();
}
catch (SqlException ex) {
MessageBox.Show(ex.ToString);
}
|
|
|
|
|
Ever heard of SQL injection?
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
Yes, I do.
But didn't wanted to confuse this guy with such fundas. Seems to be a Beginner.
|
|
|
|
|
If he's that much a beginner, it's all just as confusing, so you could have used parameters. Doing so now will confuse him, so we best leave it.
|
|
|
|
|
I appreciate your good intent on getting him started with minimum pain and confusion.
At the same time, if we can make him understand secure programming concepts even at the inception it would be good. Isn't it?
|
|
|
|
|
thanks for your reply
But this shows the error to conver into string
|
|
|
|
|
I've been reading a lot of posts on how to use delegates to communicated between two forms. However, in every example I have the problem with the strucutre of the examples. In every case I've seen there is a main form, that delegates a function to another form. However the main form first creates the second form and then sends the data that way:
For example:
<br />
private void btnSend_Click(object sender, System.EventArgs e)<br />
{<br />
Form2 frm= new Form2();<br />
delPassData del=new delPassData(frm.funData);<br />
del(this.textBox1);<br />
frm.Show();<br />
}<br />
This is great except I have the issue where once another completely seperate form is created, some information is inputted by the user and then it closes. When this window closes I want to alert the first (main form) that this has happened so it can do some of its own calculations.
From what I've read delegates are the way to go but I have been unable to find a method to make this work. Thanks for your time and any help you give!
David
|
|
|
|
|
DavidNelson wrote: This is great except I have the issue where once another completely seperate form is created, some information is inputted by the user and then it closes. When this window closes I want to alert the first (main form) that this has happened so it can do some of its own calculations.
You can register a delegate with the Form.Closed[^] event. When the second form closes, it will raise this event. Alternatively, you can add an event to the second form. The event can be accompanied by a custom EventArgs derived class you create. This custom event class will carry additional information necessary for the first main form to make its calculations. In the second form, override the OnClosed method. Raise your custom event there. Register a delegate with the event in order to respond to it.
You can skip using events all together if the main form has access to the second form. In the second form, add properties representing the user entered information. The main form can access those properties after the second form is closed.
|
|
|
|
|