|
Hi Goutam,
your code worked, thanks a lot, thnx for teaching the tag property. I have one more question for you. I am using a stored procedure to insert data into two tables in sql 2008 server. Now while handling exception i am using exception code to check the exception and accordingly i am showing the error message to the user.Can u tell me a better option to do the same.
==================================================================
Public Sub rtrnQry(ByVal usrNm As String, ByVal psWd As String, ByVal fNm As String, _
ByVal lNm As String, ByVal empId As Integer, ByVal proNm As String, ByVal aDm As String, ByVal rowno As Integer)
Try
Using cn As New SqlConnection(sqlConnStr)
cn.Open()
Using cmd As New SqlCommand("InsrtLogin", cn)
With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.AddWithValue("@empid", empId)
.Parameters.AddWithValue("@username", usrNm)
.Parameters.AddWithValue("@password", psWd)
.Parameters.AddWithValue("@firstname", fNm)
.Parameters.AddWithValue("@lastname", lNm)
.Parameters.AddWithValue("@adminpri", aDm)
.Parameters.AddWithValue("@proName", proNm)
.ExecuteNonQuery()
End With
End Using
End Using
Catch ex As SqlException
If chkBox1_Crtusr.Checked Then
If ex.Number.Equals(2627) Then 'Exception code for Primary Key Violation
MsgBox("Duplicate Employee ID cannot be inserted. Violation of Primary Key " & _
"Constraint Occured. Enter an unique value.Please check row number : 1", MsgBoxStyle.Critical, "Error")
Else
MsgBox(ex.ToString)
End If
If ex.Number.Equals(208) Then
MsgBox("Invalid Table Name. Check the Sql String.", MsgBoxStyle.Critical, "Error")
End If
End If
If chkBox2_Crtusr.Checked Then
If ex.Number.Equals(2627) Then 'Exception code for Primary Key Violation
MsgBox("Duplicate Employee ID cannot be inserted. Violation of Primary Key " & _
"Constraint Occured. Enter an unique value.Please check row number : 2", MsgBoxStyle.Critical, "Error")
Else
MsgBox(ex.ToString)
End If
If ex.Number.Equals(208) Then
MsgBox("Invalid Table Name. Check the Sql String.", MsgBoxStyle.Critical, "Error")
End If
================================Now i am calling the above proc ===========================
Private Sub btnSubmit_CrtMul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit_CrtMul.Click
Dim cnt As Integer = 0
Try
If chkBox1_Crtusr.Checked Then
rtrnQry(txtUsrNm_1.Text, txtPswd_1.Text, txtFName_1.Text, txtLName_1.Text, txtEmpID_1.Text, cmbProNm1.SelectedItem, cmbAdmin1.SelectedItem, 1)
Dim sqlLogin As String = "Select * from login where user_name ='" & txtUsrNm_1.Text & "'"
Dim usrVerified As String = DataStore.ExecuteScalar(sqlLogin, sqlConnStr)
If usrVerified.Length > 0 Then
Call ClearData(1)
cnt = cnt + 1
End If
End If
If chkBox2_Crtusr.Checked Then
rtrnQry(txtUsrNm_2.Text, txtPswd_2.Text, txtFName_2.Text, txtLName_2.Text, txtEmpID_2.Text, cmbProNm2.SelectedItem, cmbAdmin2.SelectedItem, 2)
Dim sqlLogin As String = "Select * from login where user_name ='" & txtUsrNm_2.Text & "'"
Dim usrVerified As String = DataStore.ExecuteScalar(sqlLogin, sqlConnStr)
If usrVerified.Length > 0 Then
Call ClearData(2)
cnt = cnt + 1
End If
End If
If chkBox3_Crtusr.Checked Then
rtrnQry(txtUsrNm_3.Text, txtPswd_3.Text, txtFName_3.Text, txtLName_3.Text, txtEmpID_3.Text, cmbProNm3.SelectedItem, cmbAdmin3.SelectedItem, 3)
Dim sqlLogin As String = "Select * from login where user_name ='" & txtUsrNm_3.Text & "'"
Dim usrVerified As String = DataStore.ExecuteScalar(sqlLogin, sqlConnStr)
If usrVerified.Length > 0 Then
Call ClearData(3)
cnt = cnt + 1
End If
End If
================================================================================================
Now when i am doing this, for each exception the error message is appearing twice, i need to take care of that as well. Please Help, Thanks in advance
|
|
|
|
|
|
Hello. I've got a bit of a strange error and I can't seem to find much information about ways to fix it.
I have a ClickOnce deployed application that is accessed by multiple clients, all with various Windows operating systems. It seems this error only occurs for those with Windows XP, but not for all Windows XP users.
I have a timer that kicks off every 10 minutes that makes a call to ApplicationDeployment.CurrentDeployment.CheckForUpdate(). Within this call, I get the exception --
Error: System.Deployment.Application.InvalidDeploymentException: Exception reading manifest from http://server/AppName.Client.application: the manifest may not be valid or the file could not be opened. ---> System.Deployment.Application.InvalidDeploymentException: Deployment manifest is not semantically valid. ---> System.Deployment.Application.InvalidDeploymentException: The name of the application reference identity as invalid characters: AppName.Client.exe.
at System.Deployment.Application.Manifest.AssemblyManifest.ValidateApplicationDependency(DependencyAssembly da)
at System.Deployment.Application.Manifest.AssemblyManifest.ValidateSemanticsForDeploymentRole()
--- End of inner exception stack trace ---
at System.Deployment.Application.Manifest.AssemblyManifest.ValidateSemanticsForDeploymentRole()
at System.Deployment.Application.Manifest.AssemblyManifest.ValidateSemantics(ManifestType manifestType)
at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
--- End of inner exception stack trace ---
at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirect(SubscriptionStore subStore, Uri sourceUri, TempFile tempFile, IDownloadNotification notification, DownloadOptions options, ServerInformation serverInformation)
at System.Deployment.Application.DownloadManager.DownloadDeploymentManifest(SubscriptionStore subStore, Uri sourceUri, TempFile tempFile, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.DeploymentManager.BindCore(Boolean blocking, TempFile tempDeploy, TempDirectory tempAppDir, FileStream refTransaction, String productName)
at System.Deployment.Application.DeploymentManager.Bind()
at System.Deployment.Application.ApplicationDeployment.CheckForDetailedUpdate()
at System.Deployment.Application.ApplicationDeployment.CheckForUpdate()
at AppName.Client.MainForm.WatchForDeployment() in D:\AppName\MainForm.cs
If anyone else is familiar with this exception and has some ideas about how to fix it, I'm all ears!!
Thanks!!
Mia
|
|
|
|
|
hi, try to following this steps.
Clean your solution.
Delete all files and folders from your drop site.
Rebuild all.
Republish.
On the client side, remove all previous versions of the deployment.
Then reinstall. This fixed it for my team.
Find more information on this[^] link.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Hi,
In my application, I have a gridview which is visible with a blank row on Page_Load. The GV has 4 columns of which the first column is an editable textbox. The rest 3 are bound fields. When I enter a valid ID in the textbox cell and hit the Enter key(TextChanged Event), the rest of the 3 fields are bound and a new empty row is created below this row. But my problem is , when I enter the second data and hit Enter, the first row is lost and is replaced with this second row( Datatable not holding values on Postback). Kindly help...!!!
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
if (ID valid and data returned)
{
Addnewemptyrow; //For next input
Bind data to current row;
}
if(Invalid ID and data not returned)
{
Cells[1].Text = ""; // Clear the current row values(Make it as a new row)
Cells[2].Text = "";
Cells[3].Text = "";
}
|
|
|
|
|
First, this should have been posted to the ASP.NET forum
During the postback the new values must be persisted to the datasource for your grid. Otherwise, when the grid is re-bound it course knows nothing about the new row.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
how to create web organisation chart using mysql database in C#, ASP.net. Anybody please help me.
|
|
|
|
|
What have you tried so far?
Some third party products provide these features[^].
|
|
|
|
|
I downloaded some organisation chart application in google but it is giving errors and i am not getting proper link. i am using mysql database. If u have any C#.net mysql database organisation chart application please formard me.
Please give any download links related to above if you know. thanks in advance.
modified on Friday, July 23, 2010 3:28 AM
|
|
|
|
|
HOw can i give answer of any question ,that is call by any person about my previous question
|
|
|
|
|
If you mean this question[^], you can use the "Add comment" selector beneath the answers to post a reply to the person who gave the answer.
It's time for a new signature.
|
|
|
|
|
Provide a link to your previous question.
|
|
|
|
|
i written below code to execute it is running but not restoring to database. If you know please reply me.
public void restore_data()
{
StreamReader file = new StreamReader("E:\\BackupMysql1\\travel.sql");
string cmd = string.Format(@"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysql.exe -u{0} -p(1) -h{2} (3) < {4} ", "root","password1#", "192.168.2.50", "travel", "E:\\BackupMysql1\\travel.sql");
ProcessStartInfo proc = new ProcessStartInfo("cmd", @"/C " + cmd);
//proc.RedirectStandardInput = true;
//proc.RedirectStandardOutput = false;
proc.Arguments = cmd;
proc.UseShellExecute = false;
//Process p = Process.Start(proc);
string res;
//res = file.ReadToEnd();
//p.WaitForExit();
//file.Close();
Process p = new Process();
p.StartInfo = proc;
p.Start();
//res = file.ReadToEnd();
p.WaitForExit();
}
|
|
|
|
|
I don't really understand the code but I did notice what looks like incorrect use of parentheses () instead of braces {} around parameter identities 1 and 3 in the line:
string cmd = string.Format(@"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysql.exe -u{0} -p(1) -h{2} (3) < {4} ",
"root","password1#", "192.168.2.50", "travel", "E:\\BackupMysql1\\travel.sql");
It's time for a new signature.
|
|
|
|
|
You don't need to use cmd to run the mysql process. You've only served to complicate your process here.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
problem solved now it is working thank you for all who replied to me
|
|
|
|
|
U can execute through Mysqlcommand as a script.
|
|
|
|
|
Hi All,
I have an application with sends request to a C++ CGI. The response stream comes with a delimiter ( ASC (143) ). I used ASCIIEncoding which returns the data correctly buy wrongly decoded delimiter (I got "?" instead of ASC 143).
I tried UTF7Encoding which returned the delimiter correctly but some data are lost. Does any one has solution for this? I cannot cannot change the CGI layer as its servers as router of more of our legacy applications and my Team Leaders feels that CGI is in perfect shape.
Earlier answers would be appreciated. Thanks in ASAP.
|
|
|
|
|
You have an encoding problem, which you should try and solve using the Encoding class.
There is no such thing as an extended ASCII encoding, or almost everything is an extended ASCII encoding, i.e. most encodings use more than 128 characters and keep the first 128 compatible with ASCII for obvious reasons.
Try using Encoding encoding=new Encoding(codepage); where codepage is an appropriate integer value. In Western-Europe 1252 would be the first one to try. I can't tell for your region though.
Once you have the right Encoding object, either use some of its methods to perform a conversion, or better yet, pass it as an extra parameter to your file operations, e.g. File.ReadAllText(String, Encoding)
|
|
|
|
|
|
Hi,
I am new to Web service. Using ASMX web service, the live data from the database can be shown in Xcelius Dashboard. Sample helloworld.asmx as below used to show "Hello World" in xcelsius dashboard. Xcelsius only support asmx.
<%@ WebService Language="C#"
Class="ProgWS.Ch02.HelloWorldService" %>
using System.Web.Services;
namespace ProgWS.Ch02
{
public class HelloWorldService: WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
I have tried by combining code from www.jonasjohn.de/snippets/csharp/sql-connection-example.htm with above code, I am not succeed.
I would appreciate if you could let me know the sample ASMX C# program to connect SQL Server and return data from a table (adventureworks.Person.Contact.FirstName).
Thanks.
modified on Monday, July 19, 2010 10:38 AM
|
|
|
|
|
You connect to SQL Server the same you normally do, wrapping it in a Web Service doesn't change anything.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks for the quick reply, Mark. I have updated as per the "How to get an answer to your question" #7.
I have tried Helloworld.asmx, works fine. I can use the results in xcelsius.
<pre>
<%@ WebService Language="C#"
Class="ProgWS.Ch02.HelloWorldService" %>
using System.Web.Services;
namespace ProgWS.Ch02
{
public class HelloWorldService: WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
</pre>
I have tried the below code and got the "This web service does not conform to WS-I Basic Profile v1.1." error.
<pre>
<%@ WebService Language="C#"
Class="csbook.ch15.Example15_3" %>
using System.Web.Services;
using System;
using System.Data;
using System.Data.SqlClient;
namespace csbook.ch15 {
class Example15_3 {
static void Main(string[] args) {
// create an open the connection
SqlConnection conn =
new SqlConnection("Data Source=philshiv;"
+ "Initial Catalog=AdventureWorks;"
+ "User ID=sa;Password=changeme");
conn.Open();
// create a SqlCommand object for this connection
SqlCommand command = conn.CreateCommand();
command.CommandText = "Select * from Person.Contact";
command.CommandType = CommandType.Text;
// execute the command that returns a SqlDataReader
SqlDataReader reader = command.ExecuteReader();
// display the results
while (reader.Read()) {
string output = reader["CompanyName"].ToString();
Console.WriteLine(output);
}
// close the connection
reader.Close();
conn.Close();
}
}
}
</pre>
Thanks for your time. Could you please help me to resolve the issue.
Thanks
modified on Monday, July 19, 2010 3:45 PM
|
|
|
|
|
|
Thanks for the quick reply, Mark. I have updated as per the "How to get an answer to your question" #7.
I have tried Helloworld.asmx, works fine. I can use the results in xcelsius.
<pre>
<%@ WebService Language="C#"
Class="ProgWS.Ch02.HelloWorldService" %>
using System.Web.Services;
namespace ProgWS.Ch02
{
public class HelloWorldService: WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
</pre>
I have tried the below code and got the "This web service does not conform to WS-I Basic Profile v1.1." error.
<pre>
<%@ WebService Language="C#"
Class="csbook.ch15.Example15_3" %>
using System.Web.Services;
using System;
using System.Data;
using System.Data.SqlClient;
namespace csbook.ch15 {
class Example15_3 {
static void Main(string[] args) {
// create an open the connection
SqlConnection conn =
new SqlConnection("Data Source=philshiv;"
+ "Initial Catalog=AdventureWorks;"
+ "User ID=sa;Password=changeme");
conn.Open();
// create a SqlCommand object for this connection
SqlCommand command = conn.CreateCommand();
command.CommandText = "Select * from Person.Contact";
command.CommandType = CommandType.Text;
// execute the command that returns a SqlDataReader
SqlDataReader reader = command.ExecuteReader();
// display the results
while (reader.Read()) {
string output = reader["CompanyName"].ToString();
Console.WriteLine(output);
}
// close the connection
reader.Close();
conn.Close();
}
}
}
</pre>
Thanks for your time. Could you please help me to resolve the issue.
Thanks
|
|
|
|
|