15,891,372 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 10248768 (Top 42 by date)
Member 10248768
18-Aug-14 6:14am
View
Dear NeoMayank
Thank you for replying to my query/question on such short notice. I know how to create parametrized constructor of login form(frmLogin). But i am just wondering on how to assign value of variable:mid from login form which contains manager_id of currently logged in manager of application to field:created_by in table:UserDetail2 through form(frmUser) in c# windows forms with sql server 2008? Can you show me a sample on how it needs to be done? I hope you are not annoyed with my reply! Reply please!? I hope i get reply from you Sir!
Member 10248768
23-Jul-14 8:06am
View
You are correct i will write pseudo code for that and will ask you sir.
Member 10248768
22-Jul-14 0:02am
View
Dear RyanDev and j snooze
the value of user type of normal user:0 and value user type of manager:1 in my table:UserDetail in sql server 2008.
Given below is my c# code of frmLogin(login form) which i have created:
using System.Data.SqlClient;
namespace Mini_Project
{
public partial class frmLogin : Form
{
public frmLogin()
{
InitializeComponent();
}
private void btnLogin_Click(object sender, EventArgs e)
{
if ((txtPassword.Text == "password") && (txtUsername.Text.ToLower() == "admin"))
{
MDIParent1 h = new MDIParent1();
h.Show();
this.Close();
}
else
{
string username = txtUsername.Text;
string password = txtPassword.Text;
bool validUser = ValidateUser(username, password);
if (validUser)
{
MDIParent1 m = new MDIParent1();
m.Show();
this.Close();
}
else
{
MessageBox.Show("Invalid user name or password. Please try with another user name or password", "Task", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtUsername.Focus();
}
}
}
private bool ValidateUser(string username, string password)
{
bool success = false;
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Task;Integrated Security=true");
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd = new SqlCommand("Select @count = Count(*) from [dbo].[UserDetail] where username=@username and password=@password", conn);
cmd.Parameters.AddWithValue("@username", txtUsername.Text);
cmd.Parameters.AddWithValue("@password", txtPassword.Text);
cmd.Parameters.Add("@count", SqlDbType.Int).Direction = ParameterDirection.Output;
conn.Open();
cmd.ExecuteNonQuery();
if (Convert.ToInt32(cmd.Parameters["@count"].Value) > 0)
{
success = true;
}
else
{
success = false;
}
conn.Close();
return success;
}
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
Application.Exit();
}
The above code works OK! but not the way i want.
What i want is when a normal user of user_type:0 logs into the application then i want addManagerToolStripMenuItem and addUserToolStripMenuItem should be disabled for that user when he enters into the application.
When an manager user of user_type:1 logins into the application then i want addUserToolStripMenuItem only should be enabled for that user when he enters into the application.
So tell me what modifications of c# code must i do and where to achieve my required result?! Reply please! I am waiting for your reply! I hope i get a reply !
Member 10248768
17-Jul-14 1:11am
View
Dear CPallini
I think that your code should do the trick! But can you show/send me sample on how to add a field(failure_count) to user table which increments upon each failure login and resets it to 0 upon each successful login from c# windows forms?
Given below is my structure of my table named:user in sql server 2008:
ColumnName DataType AllowNulls
user_first_name nvarchar(50) Yes
user_last_name nvarchar(50) Yes
username nvarchar(30) Yes
user_id(auto-increment) Int No
password nvarchar(15) Yes
user_dob date Yes
user_sex nvarchar(20) Yes
email nvarchar(50) Yes
user_type Int Yes
row_upd_date datetime Yes
created_by smallint Yes
Can you guide me/help me on how to add and implement failure_count field in table user which increments by 1 upon each failure login and resets to 0 upon successful login from c# windows forms? Reply Please?! I hope i get a reply from You!
Member 10248768
17-Jul-14 0:21am
View
Dear Member10950750
Thank you for replying to my question/query on such short notice.
However i cannot understand what you mean by "saving the "hitcount" in database from "else" block in order to check the hitcount on behalf of username and password to restrict his login when that particular user tries to login again after 3 failed attempts"? Should i need to include hitcount as a field in my table named:User in sql server 2008? If so tell me how to increment hitcount on each failure login of that user until 3 and reset it to 0 on successful login? Can explain it to little briefly because i cant understand what you are trying to say? Reply Please Sir?! I am waiting for your reply! I hope i get a reply from you Sir!
Member 10248768
15-Jul-14 7:30am
View
Dear Mr.Wes Aday
Thank you for replying to my question on such short notice.
Is TabIndex property of winsock control in c# windows forms is equivalent of Index property of winsock control in vb6? Or are you saying/telling that i should put winsock control inside an Array List class or should i need to put my winsock control inside Panel control/group box control?
If not can show me a sample/send me links on how to allocate/initialize index /index property of a textbox control in a collection in c# windows forms?! Reply please Sir! I am waiting for your reply!
Member 10248768
15-Jul-14 1:08am
View
Dear johannesnestler
Yesterday night i did a research and found out a solution that worked for making winsock control(Winsock1) of client application(Winsock client) to connect to server application(Winsock server) which has a winsock control(Socket).
But unfortunately it was in vb6 code.! So my client application(Winsock client) which has winsock control(Winsock1) c# code dont require any modifications!
However my server application(Winsock server) which has winsock control(Socket) requires some modifications.
Given below is vb6 code modification of Winsock server(server application):
Option Explicit
Dim iSockets As Integer
Dim sServerMsg As String
Dim sRequestID As String
Private Sub Form_Load()
lblHostID.Caption = Socket(0).LocalHostName
lblAddress.Caption = Socket(0).LocalIP
Socket(0).LocalPort = 1007
sServerMsg = "Listening to port: " & Socket(0).LocalPort
List1.AddItem (sServerMsg)
Socket(0).Listen
End Sub
Private Sub socket_Close(Index As Integer)
sServerMsg = "Connection closed: " & Socket(Index).RemoteHostIP
List1.AddItem (sServerMsg)
Socket(Index).Close
Unload Socket(Index)
iSockets = iSockets - 1
lblConnections.Caption = iSockets
End Sub
Private Sub socket_ConnectionRequest(Index As Integer, ByVal requestID As Long)
sServerMsg = "Connection request id " & requestID & " from " & Socket(Index).RemoteHostIP
If Index = 0 Then
List1.AddItem (sServerMsg)
sRequestID = requestID
iSockets = iSockets + 1
lblConnections.Caption = iSockets
Load Socket(iSockets)
Socket(iSockets).LocalPort = 1007
Socket(iSockets).Accept requestID
End If
End Sub
So in above vb6 code they have/i have found that connection was established between client application(Winsock client) and server application(Winsock server) through declaration and use of control array of winsock control named:Socket in Winsock server(server application).
I have tried the above code in vb6 of client application(Winsock client) and server application(Winsock server) and it Works!
The problem is i dont know how to translate/interpret/replicate the above vb6 code that i have given above in c# windows forms! Can anyone help me on how to create control array of winsock control(Socket) in server application(Winsock server) and help me manipulate control array of winsock control(Socket) in Winsock server(server application)?
Can anyone help me/guide me solve my problem! Any help/guidance in solving of this problem would be greatly appreciated! Reply please Sir regarding this suggestion! I hope i get reply from you Sir!
Member 10248768
14-Jul-14 8:16am
View
Dear johannesnestler Winsock1.CtlState represents the state of my winsock control.My winsock control named:Winsock has a CtlState property which in design time shows:0-sckClosed. The CtlState is of short data type.
Can you at least tell me what is equivalent of State property of winsock control of vb6 in c# windows forms of winsock control?,Answer to this question would really help me figure out the error and solving it. Reply please!
Member 10248768
14-Jul-14 7:52am
View
Dear Mr.RyanDev
I also have another question
Given below is my c# code of Winsock client(Client application) using Winsock1(winsock control) for connection with/to Winsock server(Server application) using Socket(winsock control)
Winsock Client c# code:
private void btnConnect_Click(object sender, EventArgs e)
{
Winsock1.RemoteHost = "192.168.0.118" ;//Change this to your host ip
Winsock1.RemotePort = 7777;
Winsock1.Connect();
shpGo.Visible=true;
txtPrice.Focus();
}
Winsock server c# code:
private void Form1_Load(object sender, EventArgs e)
{
txtHostID.Text = Socket.LocalHostName;
txtAddress.Text = Socket.LocalIP;
Socket.LocalPort = 7777;
sServerMsg = "Listening to port: " + Socket.LocalPort;
listBox1.Items.Add(sServerMsg);
Socket.Listen();
}
private void Socket_ConnectionRequest(object sender, AxMSWinsockLib.DMSWinsockControlEvents_ConnectionRequestEvent e)
{
sServerMsg = "Connection request id " + e.requestID + " from " + Socket.RemoteHostIP;
listBox1.Items.Add(sServerMsg);
sRequestID = e.requestID.ToString();
iSockets = iSockets + 1;
txtConnections.Text = iSockets.ToString();
}
So my question is have done connection correctly for Winsock client(client application) using winsock control named:Winsock1 to connect to/with Winsock server(Server application) which has a winsock control named:Socket?
I am asking you this because i believe there must be problem/error of connection between Winsock client(client application) and Winsock server(Server application) using winsock controls? If so can you point what mistakes have i made and what must be done to rectify that mistake? Reply please Sir! I hope i get reply from you Sir!
Member 10248768
14-Jul-14 7:29am
View
Dear RyanDev
Thank for replying to my question on such short notice.
I am stuck at given below c# code of Form1 of Winsock client(client application):
private void btnSend_Click(object sender, EventArgs e)
{
if(Winsock1.CtlState==2)
{
Winsock1.SendData(txtPrice.Text);
shpGo.Visible =true;
label3.Text = "Sending Data";
}
else
{
shpGo.Visible=false;
shpWait.Visible=false;
shpError.Visible =true;
label3.Text = "Not currently connected to host";
}
}
Since after connection with client and server application.After i enter data in txtPrice(textbox control in Form1 of Winsock client) and press/click btnSend(button control) i get message:"Not currently connected to host" in my label3(label control). So my question is how to make my winsock control named:Winsock1 of Winsock client(client application) to connect to Winsock server(Server application) which has a winsock control named:Socket? Reply please?! I am waiting for your reply Sir!
Member 10248768
4-Jul-14 6:35am
View
Well Mr.OriginalGriff
Thank you for replying to my query on such short notice. But in vb6 we can create a control array of winsock control for a/that winsock control using index property of that winsock control. Can we repeat the same here? If so can you show me a sample?! Reply please? I am waiting for your reply Sir.
Member 10248768
4-Jul-14 5:02am
View
Dear Mr.OriginalGriff
Sorry for troubling you again
I tried your solution again but my question is after creating control array named:mySockets for axWinsock1(winsock control in my c# windows form) when i click my properties windows/form properties windows i should get mySockets[0] axMSWinsockLib.axWinsock but instead why i am still getting axWinsock1 axMSWinsockLib.axWinsock on my properties window. Kindly help me/clarify this final doubt/question for me Please? I hope i get your reply! If you want can i post my entire code(even designer.cs code) of creation of axWinsock1 and mySockets so that it may help you/me to find the mistakes and fix it in order to get required output. Reply please! i am waiting for your reply!
Member 10248768
2-Jul-14 0:10am
View
Dear Mr.gggustafson
Thank you for replying to my query on such short notice. I have only one question: Have i correctly created control array of winsock control named:sckClient and correctly assigned it to winsock control named:axWinsock5 in my form named:Form1 in c# windows forms? That is what i need to know! If not Tell me,help me/guide me on how to create control array of winsock control named:sckClient and initializing it to winsock control named: axWinsock5 in form named:Form1 in c# windows forms? Reply please?! I am waiting for your reply Sir!
Member 10248768
30-Jun-14 6:36am
View
Thank you Mr.Rohit R Chavan
Thank you answering to my query on such short notice. I know that you are correct. I will try to implement the concept in my c# win forms project as soon as possible and will let you know.
Member 10248768
23-Jun-14 1:42am
View
Thank Mr.OriginalGriff
I just now tried your solution and It Works! Thank you and God Bless You Mr.OriginalGriff You are a TRUE Life Saver for me. This is what i wanted exactly! Thank you!
Member 10248768
20-Jun-14 3:53am
View
Hi Pikoh
thanks for your solution on such short notice.
I just now tried your solution but i am getting compile error when declaring Dictionary.Given below is my line in c#:
Dictionary<string,> pCollConn;
here after "," in dictionary i am getting compile error message "Type expected" Tell me/guide me on how to resolve this problem? Reply please?
where pCollConn is name of my dictionary
Member 10248768
20-Jun-14 3:22am
View
Dear Pikoh thanks for replying to my question on such short notice. Yes i want to able to access a collection of integers by an index in c# windows forms!
Member 10248768
18-Jun-14 0:50am
View
Thanks for replying to my query on such short notice Mr.RyanDev
Ok i have 2 list boxes in my form(frmGetSystemData).
So 1st listbox named:lstIP displays ManufacturerName along with DCS_ip_address
2nd listbox named:lstDialyzerID displays dialyserID along with patient_first_name,patient_last_name along with patient_id
What i want is after selecting an item from both lstIP and lstDialyzerID when i click on btnUpdateDialyzer(button) i want ManufacturerName from lstIP,dialyserID,patient_first_name,patient_last_name along with patient_id from lstDialyzerID.i want these to be displayed/datas binded into listview(lvwConnections) in c# windows forms.
That is what i want! Tell me/guide me on how to achieve this required result? I have browsed through net regarding finding solution to this problem but in vain and with no success. Can anyone help me/guide me please on how to achieve this required result?!
Member 10248768
17-Jun-14 0:42am
View
Dear Mr.Sergey Alexandrovich Kryukov
Thank for replying to my query. I know that your solution is correct. I will try your solution today and if every thing comes correct i will post/contribute(the correct answer/c# code) in this forum. So that other users/members will not commit the same mistake as i did and that i have a chance to teach them the correct solution on what should be done regarding this problem.
Member 10248768
13-Jun-14 0:08am
View
OK I agree Mr.Dave Kreskowiak. I wont you have my word! I will find another way/method to solve my problem. Sorry for causing any discomfort to you or any other members in this forum! Sorry for my action! I deeply apologize for my action!. It wont happen again.
Member 10248768
12-Jun-14 5:39am
View
No sckClient is name of my winsock control in MDIForm1 which is a mdi parent form to all other child forms in vb6 adodb with Ms access. I did not declare sckClient as an array in vb6. Reply please?
Member 10248768
12-Jun-14 3:00am
View
Dear Mr.Sergey Alexandrovich Kryukov
I have modified the line of sckClient.SendData of timer in c# given below:
sckClient.SendData(((char)250).ToString()+((char)0).ToString()+((char)105).ToString()+((char)0).ToString()+((char)0).ToString()+((char)0).ToString()+((char)0).ToString()+((char)0).ToString()+((char)0).ToString()+((char)251).ToString());
Could this do the trick for me in achieving my required result? Reply please?!
Member 10248768
6-Jun-14 7:52am
View
Dear Peter Leow
Thank you for solution.It worked perfectly! Just what i needed. My God you are a genius in sql queries and string functions! Thank you.You saved me hell a lot of trouble.God bless you.
Member 10248768
6-Jun-14 5:06am
View
Thanks Mr.Peter Leow Your solution worked perfectly for me! Thanks your help. I have only one last question is it possible to have a trial of zeros proceeding with patient_id in the same query? Is it possible? Reply please!?
Member 10248768
2-Jun-14 0:16am
View
Dear Mr.gggustafson
Sorry for posting my comment 2 days late. I apologize for that.!
Thanks for understanding and replying to my question on such short notice Mr.gggustafson. That's exactly what i want! Tell/guide me on how to achieve the same functionality of hscrollbar control that i achieved in vb6 with Ms access using Adodb in c# windows forms with sql server2008? Reply please? I am waiting for your reply Sir!
Member 10248768
29-May-14 3:26am
View
Thanks syed shanu for your solution.Your code works fine!But how to delete multiple checked items from listview with checkboxes property enabled:true from c# windows forms with sql server2008 using the above code?Reply please?
Member 10248768
29-May-14 2:17am
View
You are correct thank you!
Member 10248768
28-May-14 6:18am
View
Hi i just now tried your solution and i am not getting required result.Second i have already embed the code you gave above in my loadPatient() function in frmPatient before posting this question. Tell me what should i do to get required output? Reply please?
Member 10248768
28-May-14 6:10am
View
Hi i just now executed the above query in sql server2008 and the query works perfectly no flaws. I believe the error is in loadPatient() function in frmPatient and i have to do some modifications in loadPatient() function in frmPatient.Tell me/guide me what modifications must i do to achieve required output?Reply please?
Member 10248768
28-May-14 5:57am
View
Yes i checked it and it worked perfectly in my back-end since i was using it to bind selected row of a listview to existing form in c# windows forms with sql server2008. I can tell you i can always create another function like loadPatient() in frmPatient for binding selected item/value of combobox from one form(frmDialyzer) to existing form(frmPatient) in c# windows forms with sql server2008.Just tell/guide me what modifications must i do in that function to get required output.? Reply please?
Member 10248768
28-May-14 5:52am
View
Hi thanks for replying to my query on such short notice.
Actually i am only getting blank form of frmPatient(no datas in textboxes,comboboxes and datetimepickers)nothing more i get. Should i need to modify my c# code of loadPatient() function in frmPatient? Reply please?
Member 10248768
28-May-14 5:16am
View
Thanks for guiding me CPallini Mam i will look into it and solve my problem Mam.Thank you.
Member 10248768
27-May-14 6:21am
View
Hi Sunasara Imdadhusen
My name is vishal.Thanks for your help on such short notice.I have solved the problem by myself. Given below is my code which solved it.:
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
SqlCommand cmd = new SqlCommand("Select r.errorCode,Convert(varchar,r.dialysis_date,106),pn.patient_first_name,pn.patient_last_name,d.manufacturer,d.dialyzer_size,Convert(varchar,r.start_date,108),Convert(varchar,r.end_date,108),d.packed_volume,r.bundle_vol,t.Technician_first_name,t.Technician_last_name from dialyser d,patient_name pn,reprocessor r,Techniciandetail t where pn.patient_id=d.patient_id and r.dialyzer_id=d.dialyserID and t.technician_id=r.technician_id and d.deleted_status=0 and d.closed_status=0 and pn.status=1 and r.errorCode>105 order by pn.patient_first_name,pn.patient_last_name", conn);
conn.Open();
SqlDataReader dr;
dr = cmd.ExecuteReader();
table.AddCell(new Phrase(new Chunk("Reprocessing Date", NormalFont)));
table.AddCell(new Phrase(new Chunk("Patient Name", NormalFont)));
table.AddCell(new Phrase(new Chunk("Dialyzer(Manufacturer,Size)", NormalFont)));
table.AddCell(new Phrase(new Chunk("Time Start", NormalFont)));
table.AddCell(new Phrase(new Chunk("Time End", NormalFont)));
table.AddCell(new Phrase(new Chunk("Time Taken", NormalFont)));
table.AddCell(new Phrase(new Chunk("PV", NormalFont)));
table.AddCell(new Phrase(new Chunk("BV", NormalFont)));
table.AddCell(new Phrase(new Chunk("Error", NormalFont)));
table.AddCell(new Phrase(new Chunk("Verification", NormalFont)));
while(dr.Read())
{
table.AddCell(new Phrase(new Chunk(dr[1].ToString(),regular)));
table.AddCell(new Phrase(new Chunk(dr[2].ToString()+" "+dr[3].ToString(),regular)));
table.AddCell(new Phrase(new Chunk(dr[4].ToString()+","+dr[5].ToString(),regular)));
table.AddCell(new Phrase(new Chunk(dr[6].ToString(),regular)));
table.AddCell(new Phrase(new Chunk(dr[7].ToString(),regular)));
TimeSpan minL=Convert.ToDateTime(dr[7].ToString())-Convert.ToDateTime(dr[6].ToString());
table.AddCell(new Phrase(new Chunk(minL.ToString(),regular)));
table.AddCell(new Phrase(new Chunk(dr[8].ToString(),regular)));
table.AddCell(new Phrase(new Chunk(dr[9].ToString(),regular)));
string recur="";
if (Convert.ToInt32(dr[0].ToString()) == 106)
{
recur = "Leak Test Failed";
}
else if (Convert.ToInt32(dr[0].ToString()) == 107)
{
recur = "Bundle Volume Failed";
}
else if (Convert.ToInt32(dr[0].ToString()) == 108)
{
recur = "Priming Volume Failed";
}
table.AddCell(new Phrase(new Chunk(recur.ToString(), regular)));
table.AddCell(new Phrase(new Chunk(dr[10].ToString()+" "+dr[11].ToString(),regular)));
}
dr.Close();
Member 10248768
23-May-14 7:16am
View
Yes! Your query worked perfectly! But my last question is how to bind result of sql select query to int of string variable in c# windows forms with sql server2008? Reply please?
Member 10248768
22-May-14 0:03am
View
Yes that is exactly what i want.Tell me how to achieve it?Reply please!
Member 10248768
20-May-14 0:47am
View
Ok I can use a Panel to the same purpose like creating a label control named:lblPID and a StrokeScribe control named:barCOrg inside a Panel control and if i do is it possible to show Panel datas upon creation in c# windows forms with sql server2008 using any shell commands? Reply please.I hope i get a reply from you.
Member 10248768
19-May-14 7:59am
View
No actually i did it.Could i use panel control instead of picturebox control to achieve my required result then i could put a label control(lblPID) on top of StrokeScribe control(barCOrg). Both label and StrokeScribe control inside a panel.Could it work?Reply please.
Member 10248768
19-May-14 5:09am
View
Hey Holmes
I again deleted and created a new table named dialyser2 with same fields and respective data types and tried below code:
public frmDialyzer()
{
InitializeComponent();
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
string PatientPull = ("select p.patient_id as patient_id,n.patient_first_name as patient_fname,n.patient_last_name as patient_lname from patient_name n,patient_id p where n.patient_id=p.patient_id and n.status =1 and p.patient_id not in (select d.patient_id from dialyser2 d where d.deleted_status=0)");
SqlCommand cmd = new SqlCommand(PatientPull);
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
PatientPull = dr[1].ToString() + "_" + dr[2].ToString() + "(" + "0000" + dr[0].ToString() + ")";
cboPatientID.Items.Add(PatientPull);
}
dr.Close();
}
private void btnAssign_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
int autoGenId = -1;
cmd = new SqlCommand("Insert into dialyser2(dialyserID,manufacturer,mfr_ref_number,mfr_lot_number,mfr_date,exp_date,start_date,deleted_status,packed_volume,dialyzer_size,patient_id,row_upd_date,user_id)" + "Values(@dialyserID,@manufacturer,@mfr_ref_number,@mfr_lot_number,@mfr_date,@exp_date,@start_date,@deleted_status,@packed_volume,@dialyzer_size,@patient_id,GetDate(),@user_id);Select @autoGenId = SCOPE_IDENTITY();", conn);
cmd.Parameters.AddWithValue("@dialyserID", txtDID.Text.ToString());
cmd.Parameters.AddWithValue("@manufacturer", cboManufacturer.Text.ToString());
cmd.Parameters.AddWithValue("@mfr_ref_number", txtMFRRefNo.Text.ToString());
cmd.Parameters.AddWithValue("@mfr_lot_number", txtMFRLotNo.Text.ToString());
cmd.Parameters.AddWithValue("@mfr_date", dtMFRDate.Value);
cmd.Parameters.AddWithValue("@exp_date", dtExpDate.Value);
cmd.Parameters.AddWithValue("@start_date", dtStartDate.Value);
cmd.Parameters.AddWithValue("@deleted_status", 0);
cmd.Parameters.AddWithValue("@packed_volume", txtPVol.Text.ToString());
cmd.Parameters.AddWithValue("@dialyzer_size", cboequipmentType.Text.ToString());
cmd.Parameters.AddWithValue("@patient_id", cboPatientID.SelectedIndex);
cmd.Parameters.AddWithValue("@user_id", pUserID);
cmd.Parameters.Add("@autoGenId", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
autoGenId = Convert.ToInt32(cmd.Parameters["@autoGenId"].Value);
((MDIParent1)this.MdiParent).updateUserActivities(autoGenId, 4, cboManufacturer.Text + "Dialyzer detail was added successfully");
MessageBox.Show("Dialyzer data was successfully added", "DRRS", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
But still i am getting the same problem.Tell me how to fix my problem?Reply please?! I hope i get reply from you.
Member 10248768
19-May-14 3:38am
View
So the assignment table in sql server2008 is dialyser and the field is patient_id in dialyser. i assign pass value of patient_id from tables patient_id and patient_name into table dialyser and the assigned field in dialyser table is patient_id.So tell me/guide me on how to achieve my required result? Reply please?
Member 10248768
19-May-14 3:06am
View
Hi i just now tried your solution and i get run-time error:
SqlException was unhandled:
Must declare the scalar variable "@SelectedPatientID"
Tell me how to fix this error?Reply please?!
Member 10248768
19-May-14 3:01am
View
No that is not what i want. As you can see list of patients appear in my combobox(cboPatientID) in frmDialyzer every time when my form loads.But what i want is once i have assigned dialyzer to particular patient into dialyser table in sql server2008 through c# windows forms. I should not get the same patient in my items of combobox(cboPatientID) in frmDialyzer once the form loads to whom i have already assigned a dialyserID. That is what i want
Member 10248768
19-May-14 2:08am
View
First sorry for my delayed reply
Thanks DamithSL for your solution.It worked perfectly according to what i wanted.
Show More