|
I select the modified data from the sql server as a xml I've added an attribute to each row to tell me its state when I load this file to a dataset it does not read the stated it marks all rows as Added by default so if I want to change the state I have to loop over the table and change the rowstate property my question is Can I change the state when the data set loads the xml file or I have to loop over the table after population?
Dad
|
|
|
|
|
Why are you returning XML that is then placed into a dataset? This makes no sense at all. Its like converting an int to a string then back to an int.
Add the column to the select query then it will be in the dataset already. Otherwise, no, there is no other way except to iterate through the rows.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I've tried the xml to let me choose an intermediate method to tell the dataset the state of rows but it will be more efficient if it loads the data directly but If it does, also, How can I tell the row state? this data set will be transferred to a client where another adapter will update the client database so the dataset must tell the state of the rows which I cant do when loading the data because the column which tell the state is invented by my sql script and it does not belong to table so the data set will trait it as a normal column.
Dad
|
|
|
|
|
You are making this out to be much more difficult that it really is. This issue in particular and the entire architecture of your application from the sounds of it.
If the client can call the database to update the records why are you placing this intermediary step in between, access from the client, or better yet from a properly constructed dta accsss layer.
hadad wrote: invented by my sql script and it does not belong to table
YES it does. If it's in the select statement is will be in the dataset.
RTFM!!
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi guys does anyone know how to check if a sortedlist
is empty or not?
I tried using the 'capacity' and keys|values 'count' property but none work
Anyone with a different approach?
help
Morg
|
|
|
|
|
Capacity won't tell you if it's empty or not (if it's 0 then it's empty, but it could be empty and > 0).
Count should - what doesn't work about it?
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Cool it works fine now...it was just logic
|
|
|
|
|
Use the Count property:
SortedList<int, string> sl = new SortedList<int, string>();
sl.Add(4, "four");
sl.Add(3, "three");
MessageBox.Show(sl.Count.ToString());
Gives "2".
SortedList<int, string> sl = new SortedList<int, string>();
MessageBox.Show(sl.Count.ToString());
Gives "0".
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Why do you think that the Count property is inaccurate? Can you give an example of the exact problem you are facing.
Alan.
|
|
|
|
|
|
The count property can determine whether the list is empty or not if it is 0 so the list is empty
Dad
|
|
|
|
|
Hi I wrote the code for adding image as well as saving the image but whenever I add photos and save them the original size of the photos gets reduced.It takes size of 80,80 I commented the line but still the size of the photos is 80,80 Can somebody pls help......
<br />
private void btnAddPhotos_Click(object sender, EventArgs e)<br />
{<br />
openFileDialog.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*";<br />
openFileDialog.Multiselect = true;<br />
<br />
if (openFileDialog.ShowDialog() == DialogResult.OK)<br />
{<br />
listView1.View = View.LargeIcon;<br />
<br />
for (int c = 0; c < openFileDialog.FileNames.Length; c++)<br />
{<br />
Image i = Image.FromFile(openFileDialog.FileNames[c].ToString());<br />
Image img = i.GetThumbnailImage(256, 256, null, new IntPtr());<br />
imageList.Images.Add(img);<br />
}<br />
listView1.LargeImageList = imageList;<br />
int cntl = listView1.Items.Count;<br />
<br />
if (cntl == 1)<br />
{<br />
ListViewItem lstItem = new ListViewItem();<br />
lstItem.ImageIndex = 1;<br />
listView1.Items.Add(lstItem);<br />
}<br />
else<br />
{<br />
for (int j = cntl; j < imageList.Images.Count; j++)<br />
{<br />
ListViewItem lstItem = new ListViewItem();<br />
lstItem.ImageIndex = j;<br />
listView1.Items.Add(lstItem);<br />
}<br />
}<br />
}<br />
else<br />
{<br />
return;<br />
}<br />
}<br />
<br />
private void btnSavePhotos_Click(object sender, EventArgs e)<br />
{<br />
clsImageSettings saveFileDia = new clsImageSettings();<br />
clsImageSettings objSaveImage = new clsImageSettings();<br />
FolderBrowserDialog objFolderDai = new FolderBrowserDialog();<br />
string imgPath = "";<br />
if (listView1.Items.Count > 0)<br />
{<br />
if (objFolderDai.ShowDialog() == DialogResult.OK)<br />
{<br />
imgPath = objFolderDai.SelectedPath;<br />
<br />
for (int i = 0; i < openFileDialog.SafeFileNames.Length; i++)<br />
{<br />
string imgFilePath = openFileDialog.FileNames[i].ToString();<br />
string imgFileName = openFileDialog.SafeFileNames[i];<br />
Image imgBrighten = imageList.Images[i];<br />
objSaveImage.saveJpeg(imgPath + "\\" + imgFileName, new Bitmap(imgBrighten), 85L);<br />
}<br />
}<br />
else { return; }<br />
}<br />
else { return; }<br />
<br />
MessageBox.Show("Images Saved Succesfully @Path " + imgPath, "BatchImage Editor & Uploader");<br />
}<br />
|
|
|
|
|
Rule one: If you are going to post code fragments - especially long code fragments - use the "code block" widget (or <pre> </pre> tags) to preserve the formatting, not the "inline code" widget (or <code> </code> tags).
Rule two: From a quick scan (which is all I'll do with unformatted stuff), it is a good idea when reading in an image file to keep both the image, and the thumbnail - not keep the thumbnail and throw away the image... Would it surprise you to know that a thumbnail is 80 x 80? Suggest anything about you problem?
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I want the images to be in original size as they were before i dont want them to get small can u suggest something
|
|
|
|
|
When you save, perhaps saving the thumbnail image is not the best way to get a full size picture?
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
This can not possibly be a "good answer", as all you do is reply with yet another question...
how about providing a real suggestion?
|
|
|
|
|
Keep 'em guessing, that what I say!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Good Day All
I have a Code that Connects the VPN to a machine that is on a Different Network as mine and after the Connection is enabled, i use ado.net to access the SQL Server that is on the VPN Network and i tried the name instance of the SQL and i tried to use the IP Address to connect to it and it did not work. Here is my attempted code
private Boolean Connect_to_SQl()
{
String Constring = @"user id=sa;password=oops;Server=96.444.444.233;Database=oDirectv3";
SqlConnection con = new SqlConnection(Constring);
Boolean Status = false;
try
{
con.Open();
if (con != null)
{
Status = true;
}
else
{
Status = false;
}
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
}
return Status;
}
My code fails when i try to Open the Connection
The Remote Machine is Using SQL 2008 and the Error is
{System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, 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 RemoteUpdater.Form1.Connect_to_SQl() in C:\Work Development\Remote_Updater\RemoteUpdater\RemoteUpdater\Form1.cs:line 75}
I have used the named instance and i have permission. am a sa in that machine
Thank you
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
modified on Wednesday, April 14, 2010 10:54 AM
|
|
|
|
|
Vuyiswa Maseko wrote: and i have permission. am a sa in that machine
Sql doesn't even reach the point where it can authenticate you; it seems that it cannot find the server at all.
Some points to verify;- Is TCP/IP enabled? Open the Configuration Manager (located in the startmenu), under the node "SQL Server Network Configuration" - TCP/IP should be enabled, but is usually disabled (also the default) for security-reasons.
- Firewall?
- Can you ping the machine?
- Can you connect using a "trusted connection"? If so, then the SA-account may be locked or disabled.
Hope this helps
I are Troll
|
|
|
|
|
Good Day Eddy
The TCP/IP is enabled
Firewall is Disabled
I can Ping the Machine from my machine and i get replies
There is another user and i tried it and it failed too with the same Error
The sa user is enabled
Please look at this Document here , it has screen shots of the settings
http://www.vbforums.com/attachment.php?attachmentid=77473&d=1271315943[^]
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Vuyiswa Maseko wrote: Please look at this Document here , it has screen shots of the settings
Cool, that saves some questions. You probably also tried replacing the computername with an IP-address/port number combination?
Last thing to verify would be the Sql Browser Service[^].
What VPN-software are you using?
I are Troll
|
|
|
|
|
Good Day Eddy
i have enabled the SQl Browser and changed my Connection string to be something like this
Data Source=tcp:196.211.164.122\ABC\SUTSVR,1433;Initial Catalog=pubs;User ID=sa;Password=OOPS
and i was able to connect to the SQL Server, and i tried to run an insert on a test table, and i found errors that says the stored procedure does not exist. Because i have SQL 2000 that was installed a long time ago and i have a SQL 2008 instance, i assume it trying to connect to SQL 2000 as it might be a default instance. What i did to confirm this i wrote a query that will return the version of SQL and bind it to a Label and it came back as SQL 2000 and now my problem is that i used the correct instance name, not the SQL 2000 instance name, but it connect to SQL 2000 not SQL 2008.The SQl 2000 and SQL 2008 uses the same port 1433, how can i make SQL 2008 a default instance, because the Instance name of the SQL2000 is equal to the name of the Server (ABC)and the SQl 2008 instance is ABC\SUTSVR how do i change the default to SQL
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Both Sql Servers are installed on the same machine? There can be only one default instance[^], so if the other is on the same machine, then this will be a named instance.
The "default" instance is just the server-name without anything special. If you installed a named instance, then you have to specify that name when connection, like Server\SQLEXPRESS.
AFAIK, you cannot change the instancenames on Sql2000 or 2005 without reinstalling the server. In Sql2008, it should be possible to change the name.
I are Troll
|
|
|
|
|
Good Day Eddy
I have changed my Connection string to this
"Data Source=tcp:196.211.124.132\XCDSVR,1433;Initial Catalog=pubs;User ID=sa;Password=oops;";
and it works.
Thank you for your Help
Kind Regards
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi,
I develop a charp smart device application.
I tried to connect my Formconnexion but doesn't work for me:
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
namespace ModeDifféré
{
public partial class Connexion : Form
{
public Connexion()
{
InitializeComponent();
}
private void Connexion_load(object sender, EventArgs e)
{
createconnexion();
}
private void createconnexion()
{
}
private void button1_Click(object sender, EventArgs e)
{
string chcon = null;
SqlCeCommand command;
SqlCeDataAdapter adapter = new SqlCeDataAdapter();
adapter.TableMappings.Add("Table", "Connexion");
DataSet ds = new DataSet();
string sql = null;
string login,MotPass;
sql = "Select login from Connexion where login=@login and MotPass=@MotPass ";
string chcc= "BaseGmaoLocale.sdf;";
SqlCeConnection sqlceconn= new SqlCeConnection(chcc);
sqlceconn.Open();
try
{
sqlceconn.Open();
command = new SqlCeCommand(sql, sqlceconn);
adapter.SelectCommand = command;
adapter.Fill(ds, "SQL Temp Table");
adapter.Dispose();
command.Dispose();
sqlceconn.Close();
MessageBox.Show("Number of row(s) - " + ds.Tables[0].Rows.Count);
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
if (ds.Tables[0].Rows.Count != 0)
{
MessageBox.Show("Authentification réussie");
MenuP m = new MenuP();
m.Show();
}
else
{
MessageBox.Show("Login ou mot de passe incorrect veuillez réessayer");
}
}
}
}
4 notifications appears:
Warning 1 The variable 'chcon' is assigned but its value is never used C:\Users\Admin\Documents\Visual Studio 2008\Projects\GMAOMobile\ModeDifféré\Connexion.cs
Warning 2 The variable 'login' is declared but never used C:\Users\Admin\Documents\Visual Studio 2008\Projects\GMAOMobile\ModeDifféré\Connexion.cs
Warning 3 The variable 'MotPass' is declared but never used C:\Users\Admin\Documents\Visual Studio 2008\Projects\GMAOMobile\ModeDifféré\Connexion.cs
Warning 4 The variable 'ex' is declared but never used C:\Users\Admin\Documents\Visual Studio 2008\Projects\GMAOMobile\ModeDifféré\Connexion.cs
When running it tells me there are an error in the connexion string chcc
Can u help me
Thanks
|
|
|
|
|