|
1)No connection could be made because the target machine actively refused it
2)
System.Data.SqlClient.SqlException was unhandled
Message=Login failed for user 'sa'.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=14
LineNumber=65536
Number=18456
Procedure=""
Server=.
State=1
StackTrace:
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at TrustedParty.Keydistribute.button1_Click(Object sender, EventArgs e) in E:\E DRIVE\all proj-rar files\SKIT\TrustedParty\Keydistribute.cs:line 111
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at TrustedParty.Program.Main(String[] args) in E:\E DRIVE\all proj-rar files\SKIT\TrustedParty\Program.cs:line 22
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
|
|
|
|
|
So, put a break-point at the start of your code, single-step through it using Visual Studio (F11) when it hits the break-point, and then include in your post here on what line the error occurred.
«I'm asked why doesn't C# implement feature X all the time. The answer's always the same: because no one ever designed, specified, implemented, tested, documented, shipped that feature. All six of those things are necessary to make a feature happen. They all cost huge amounts of time, effort and money.» Eric Lippert, Microsoft, 2009
|
|
|
|
|
Have you tried google?
Eg. this might help.[^]
copy/pasting the error message in google often works miracles
|
|
|
|
|
Member 11432197 wrote: Message=Login failed for user 'sa'.
Basically the code isn't logging in correctly. There are a few causes:
- You haven't provided any password for the account "sa"
- You haven't provided the correct password for the account "sa"
- The account sa doesn't exist where you are trying to log in
- The server isn't configured to allow sql authentication (it isn't in mixed mode in the case of MS SQL server) - this is less likely
How you fix this is another matter - you need to provide the correct credentials (username and password) in either code in your web/app .config. Note that config is better as you can encrypt the information.
Slightly off topic, but logging in as "sa" (system administrator)
|
|
|
|
|
How to add an edit button on first row of gridview.
Upendra Pratap Shahi
|
|
|
|
|
|
My project is to implement the comparison between RSA and ECC.For that i need the source code of ecc for encryption and decryption.i did'nt get the proper code to implement ecc.so plz help me by providing it.
|
|
|
|
|
|
by using c# code how to transfer the entire english windows form into arabic language
|
|
|
|
|
look up satellite assemblies...
basically you define "resources" which is a table with key/value pairs. You have one for each language.
|
|
|
|
|
Hi I am binding data of same table in two different data grid view in the same form. It includes removing and filtering of the rows.
There are two biding source for the two dgv. But it sometimes it shows some weird behaviours on the data.
Can you explain what possible goes wrong.
|
|
|
|
|
Member 11431015 wrote: But it sometimes it shows some weird behaviours Please do not assume that people can guess what that means.
|
|
|
|
|
Hi, I have the following code for pressing a button in windows forms. Don`t be scared by long code, I have declared some vars and I have 2 query there. One for get first results and second is like a pagination. The problem is if I press first time on button I get some results, but if I press second time I don`t get the next results but the same. How can I change the code so if I press multiple times to get next and next results.
string defaultImage;
string lang = "en";
string selectedLang = comboBox1.SelectedItem.ToString();
int Count = 5;
int maxStatuses = Convert.ToInt32(numericUpDown3.Value);
var statusList = new List();
int lastStatusCount = 0;
switch (selectedLang)
{
case "English":
lang = "en";
break;
case "Romanian":
lang = "ro";
break;
case "Italian":
lang = "it";
break;
case "French":
lang = "fr";
break;
default:
lang = "en";
break;
}
var auth = apiConnect();
var twitterCtx = new TwitterContext(auth);
var searchResponse =
await
(from search in twitterCtx.Search
where search.Type == SearchType.Search &&
search.Query == q &&
search.Count == Count &&
search.SinceID == sinceID &&
search.SearchLanguage == lang &&
search.ResultType == ResultType.Recent
select search)
.SingleOrDefaultAsync();
if (searchResponse != null && searchResponse.Statuses != null)
{
List newStatuses = searchResponse.Statuses;
maxIDlim = newStatuses.Min(status => status.StatusID) - 1;
statusList.AddRange(newStatuses);
do
{
label19.Text = maxIDlim.ToString();
searchResponse =
await
(from search in twitterCtx.Search
where search.Type == SearchType.Search &&
search.Query == q &&
search.Count == Count &&
search.SinceID == sinceID &&
search.MaxID == maxIDlim &&
search.SearchLanguage == lang &&
search.ResultType == ResultType.Recent
select search)
.SingleOrDefaultAsync();
newStatuses = searchResponse.Statuses;
maxIDlim = newStatuses.Min(status => status.StatusID) - 1;
statusList.AddRange(newStatuses);
lastStatusCount = newStatuses.Count;
label18.Text = maxIDlim.ToString();
} while (lastStatusCount != 0 && statusList.Count < maxStatuses);
listView1.BeginUpdate();
for (int i = 0; i < statusList.Count; i++)
{
Status search = statusList[i];
if (search.User.DefaultProfileImage)
defaultImage = "NO";
else
defaultImage = "YES";
string[] row = { search.User.ScreenNameResponse, search.Text, defaultImage, search.StatusID.ToString() };
var listViewItem = new ListViewItem(row);
listView1.Items.Add(listViewItem);
}
listView1.EndUpdate();
}
|
|
|
|
|
Press a button on what? Some of your code appears to perhaps be ASP.NET related, which if that is the case then you should post your question to the specific ASP-NET Discussion Board[^] as you will get a better answer. The C# Discussion board is generally for basic questions pertaining to WinForms, WPF, and console programming.
Assuming that you are doing something to a Web Form and that you are attempting to press an HTML Button or perhaps a Web Form Control, did you check for the IsPostBack property for the page within the page/view logic there? If not, then you are repeatedly reproducing the identical page again and again. Which is what you appear to describe. A basic article describing this effect of not checking IsPostBack can be read within this basic CodeProject article[^].
I hope this points you in the right direction toward fulfilling your quest for an answer.
|
|
|
|
|
Hi anybody,
I have written DLL library in C with C function:
__declspec(dllexport) int ANB_Printf(ANB_DATAGRAM *dgram, uint8_t cmd_if_ack_nak, FILE *stream)
{
...
fprintf(stream, "* LineNo : %u\n", uint32_val);
...
}
Function ANB_Printf() writing to C FILE stream passing in function as pointer on FILE structure named *stream.
How can I DLL import and use this function considering FILE *stream parameter passing in C#:
[DllImport("anb_protocol_lib.dll")]
public static extern int ANB_Printf([MarshalAs(UnmanagedType.Struct)] ref ANB_DATAGRAM dgram, uint8_t cmd_if_ack_nak, ??? stream);
I would like use passed "stream" parameter as FileStream instance in C# and redirecting this to text file.
Thank you for your suggestions
Milos
|
|
|
|
|
The FILE structure is a C library construct and cannot be used directly in a C# program.
You will have to pass the underlying file handle instead. Then use one of the appropriate FileStream constructors to create a FileStream object from the handle.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Newbie here! I hope I have posted in the write section.
I have been stuck on a socket response and need some help.
I am able to receive the full StringBuilder response for the AsyncCallback if I place a break-point right after the:
client.BeginReceive(state.buffer, 0, state.BufferSize, 0, new AsyncCallback(ReceiveCallback), state);
But if I don't put a break-point in, the code just rips past it and nothing seems to happen and the items are not inserted into db.
Code here:
private static void Receive(Socket client)
{
Logger logger = new Logger();
string responseMSG = string.Empty;
DateTime recTime;
string tracer;
string message;
StateObject state = new StateObject();
state.workSocket = client;
Thread.Sleep(500);
client.BeginReceive(state.buffer, 0, state.BufferSize, 0, new AsyncCallback(ReceiveCallback), state);
if (state.sb.ToString() != "")
{
responseMSG = state.sb.ToString();
if (responseMSG.Length > 77)
{
if (responseMSG.Substring(77, 4) == "2610")
{
recTime = DateTime.Now;
tracer = responseMSG.Substring(126, 6).ToString();
message = responseMSG.Substring(77, responseMSG.Length - 77);
SQLHelper.AddMessageDataToExtractTable("recv", recTime, tracer, message);
}
}
else
{
CurrentState.CurrentReceiveTime = DateTime.Now;
CurrentState.CurrentReceiveTracer = "No Tracer";
CurrentState.CurrentReceiveMessage = responseMSG;
}
}
}
private static void ReceiveCallback(IAsyncResult ar)
{
//Logger logger = new Logger();
try
{
StateObject state = (StateObject)ar.AsyncState;
Socket client = state.workSocket;
int bytesRead = client.EndReceive(ar);
if (bytesRead > 0)
{
state.sb.Append(Encoding.ASCII.GetString(state.buffer, 0, bytesRead));
client.BeginReceive(state.buffer, 0, state.BufferSize, 0, new AsyncCallback(ReceiveCallback), state);
}
else
{
if (state.sb.Length > 1)
{
response = state.sb.ToString();
}
receiveDone.Set();
}
}
catch (Exception e)
{
//logger.DoLog(string.Format("{0}{1} ", DateTime.Now.ToLongTimeString(), " ReceiveCallback: " + e.ToString()));
}
}
|
|
|
|
|
I have not tried this myself, but your async routine makes no allowance for the fact that network messages can be broken into chunks, so you cannot guarantee that all the data is received in one go.
|
|
|
|
|
Thanks for the response Richard.
Any recommendations?
|
|
|
|
|
As I said, I have not tried this myself. But you need to check the documentation to see when the response event is executed, and how to tell when you have received all the data.
|
|
|
|
|
Hi
I have converted a word document into an image using c# code , the image created using code is showing transparent background in some image format and showing black back ground in some formates
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;
using Microsoft.Office.Core;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Word;
using System.Drawing.Printing;
string startupPath = @"C:\Users\infoobjects\Desktop\";
string filename1 = "Test1.doc";
var docPath = Path.Combine(startupPath, filename1);
Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
test.messageclass.MessageFilter.Register();
app.Visible = true;
var doc = app.Documents.Open(docPath);
doc.ShowGrammaticalErrors = false;
doc.ShowRevisions = false;
doc.ShowSpellingErrors = false;
if (!Directory.Exists(startupPath + "\\" + filename1.Split('.')[0]))
{
Directory.CreateDirectory(startupPath + "\\" + filename1.Split('.')[0]);
}
foreach (Microsoft.Office.Interop.Word.Window window in doc.Windows)
{
foreach (Microsoft.Office.Interop.Word.Pane pane in window.Panes)
{
pane.View.DisplayBackgrounds = true;
for (var ii = 1; ii <= pane.Pages.Count; ii++)
{
var page = pane.Pages[ii];
var bits = page.EnhMetaFileBits;
var target = Path.Combine(startupPath + "\\" + filename1.Split('.')[0], string.Format("{1}_page_{0}", ii, filename1.Split('.')[0]));
try
{
using (var ms = new MemoryStream((byte[])(bits)))
{
var image = System.Drawing.Image.FromStream(ms);
var pngTarget = Path.ChangeExtension(target, "Wmf");
image.Save(pngTarget, System.Drawing.Imaging.ImageFormat.Wmf);
}
}
catch (System.Exception ex)
{ }
}
}
}
doc.Close(Type.Missing, Type.Missing, Type.Missing);
app.Quit(Type.Missing, Type.Missing, Type.Missing);
test.messageclass.MessageFilter.Revoke();
I have also tried to recreate the same image with diff background, some results
I would appreciate any feedback as to where I'm going wrong...
|
|
|
|
|
What format(s) do you wish to use the Word Document =>Image in ? How do you wish the background to appear ?
How is what is happening now a problem for you ?
«I'm asked why doesn't C# implement feature X all the time. The answer's always the same: because no one ever designed, specified, implemented, tested, documented, shipped that feature. All six of those things are necessary to make a feature happen. They all cost huge amounts of time, effort and money.» Eric Lippert, Microsoft, 2009
|
|
|
|
|
You mentioned that the background is sometimes transparent and at other times not in different formats. Not all image formats are transparent.
Some use a special first pixel to define a special color as transparent which is only useful in 256 color (or less) images. These formats (like GIF) provide a chunky pixel-like transparency; however something like a high color photo will usually need a format that has an alpha layer which can provide varying degrees of transparency. The latter format (like PNG) can do what is called alpha-blending against a grey scale alpha channel.
Hope this helps....
|
|
|
|
|
how to merge two datagridview's into one
|
|
|
|
|
How to implement frozen property for datagridview to fix columns to the right
|
|
|
|
|