|
Here is Code Buddy...
First add App.config file into your project.
[1] Add below code in the App.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="constr" value="data source=SK-WAQASBUTT;initial catalog=Northwind;user id=waqas;Password=butt" />
</appSettings>
</configuration>
How to get the key value. code is:
First add system.configration; reference is the file. then add this code on you button click.
try
{
string consetting = ConfigurationSettings.AppSettings["constr"]; // Get the Key value from app.config.
// I'm not good in VB.Net but still a try In VB.Net get key value could like this
// String consetting As ConfigurationSettings.AppSettings["constr"]
txtconstr.Text = consetting;
}
catch(Exception ex)
{
MessageBox.Show("Exception : " + ex.Message,
"Muhammad Waqas Butt",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
See how simple is to do.
Ok please inform me if any problem occure in this code ok
<b>Muhammad Waqas Butt:->
waqasb4all@yahoo.com</b>
|
|
|
|
|
I am using sqlconnection control in vb.net and i use it for different form.
Everytime if i move my database and my application to other Computer, I need to change the connection string one by one in each form and of course this is abit troublesome for me. Any ways to change the sqlconnection string in properties only 'once', and all sqlconnection string in all forms will also change?
|
|
|
|
|
This is a frightening window into how badly designed your application is. This sort of stuff should be stored in a config file.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I did that because every form need adapter if want to connection to sql. When i drag and drop the adapter and and set sql command, a sqlconnection1 will appear.
That's why every form will have sqlconnection1. When i use other pc and copy my application, then i need to change every sqlconnection string in each form. If possible i want to set it once and all sqlconnection1.connectionstring are changed.
|
|
|
|
|
You can't do that using the "Drag and Drop" controls. It's always been better to write your own SQL connection code. You'll have to replace these connection objects with your own code that reads what the connection string should be from a config file.
A better method would be to centralize all your SQL code into a seperate class. Then, each form could use the SQL methods you expose in this class to handle all the data. This is what is meant by the "data tier" in a multiple-tier application.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Damn - you said the same as I did, but a lot more politely. I need some sleep.....
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I was feeling particularly gracious today! It's about 10pm here now, so, that'll end in about 2 hours!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Welcome to the world of programming. We tend to write code rather than drag stuff onto a pretty designer.
Seriously, the IDE lets you do this, but it's crap. You should have a central class for data access, and ideally a connection object that is reused, or even a pool, depending on the app.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Im interested when you said using one class to declare sqlconnection. Can you give me example of using it.
I know im a beginner in any programming language and only VB.Net is my first programming language and I did using code to declare sql connection but i have difficulty on it and I finally ended up with using sqldataadapter.
|
|
|
|
|
If you have a class that contains a private static sqlconnection, and sets it to null, then you can create the connection when it's first used, which is called lazy initialisation ( create it the first time it's used, otherwise return it. ). Use a property to wrap this, and the IDispose/Finaliser pattern to make sure it's cleaned up.
Then all your data access code will be in this one class ( which is good design in general ) and therefore all use this one connection. If the app is distributed, then you should use some sort of connection pool if you can, no use having every user hold a connection they are not using. But this pattern works well for local databases with only one user.
Here[^] are the MSDN docs on SQLDataAdapter - how did you use it INSTEAD of SQLConnection ? How is the DataAdapter connecting to SQL Server ? It looks to me like this class needs a SQLConnection to work, that's certainly how I use it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hey!nice to meet you,everyone.you can call me bill.can we make friends?
recently i posted a problem on the forum and havenot had a better answer.i know i am not clever.but could you please help me a little more? my question is:how to serialize(save) object into database field(SQL Server)?for a instance:
<serializable()>_
public class employee
private _name as string
private _age as string
public property name() as string
get
return me._name
end get
set(byval value as string)
me._name=value
end set
end property
.........
then,i serialized(saved) them into file:
public sub save(byval emp as employee,_
byval filepath as string,byval overwrite as boolean)
dim mode as filemode
if overwrite then
mode=filemiode.create
else
mode=filemode.createnew
end if
dim fs as new filestream(filepath,mode)
dim bf as new binaryformatter()
bf.serialize(fs,emp)
fs.close()
end sub
excitedly,i succeed.but,how to serialize(save) them into database field(SQL Server)?i have tried for many times,but failed!(maybe add dataset as interface,but i don't know how to do).please help me.i'm worrying about it.thanks a lot!
good luck and make more money! bill(in forum's name is:maaaxwell)
|
|
|
|
|
I have created several Excel VBA procedures that create a new spreadsheet, query a SQL database, and create pivot tables around the data. I would like to create an Excel function that takes an integer parameter and creates the new spreadsheets. I was able to create an xla file but it will not allow the creation of a new spreadsheet from inside a function. Is there a way to do this without creating a full blown COM object instead of an Excel add-in?
|
|
|
|
|
Hi,
I'm actually trying to show the properties of an object (line) painted on a bitmap in a scrollable control when I click over the line itself.
here is my problem:
the line is "georeferenced", so I wrote a function to convert the mouse coordinates to "geo coordinates" and perform a hit test to select the line.
It actually works if i do not use zoom.
To zoom-in I use a variable "_ScalingFactor" which is incremented by 0.05 by the zoom-in command and which is used to define the bitmap size and the translating function.
so, when i click on the control to select the line, I obtain the coords of the control not the coords of the bitmap containing the lines (the bitmap is larger then the control).
as a consequence, my hit test to select a line fails...
basically i'd need to get the mouse coords over the bitmap not over the control that contains the bitmap itself.
any help is veeery appreciated
Ciao!
Fuel2Run
p.s. sorry for my poor english.
|
|
|
|
|
You need to add the scroll values to get the co-ords to the top left of the image. And then you need to scale by your zoom factor.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi Christian,
you're quite right, but.. how do I get the scroll values from my control?
is AutoScrollPosition property?
I gave a quick try but it's not working, are there more gaps to take into account? (i.e. scrollbars dimension)
if I don't take into account the scroll values, I get the correct coords when the VScrollBar is completely down and the HScrollBar is completely on the right,
if I do, I can't find the proportion with the scaling factor and the hit test fails...
thanks again!
Fuel2Run
|
|
|
|
|
The scroll bar size does not matter, they are on the right and bottom, aren't they ?
The best thing to do in a case like this is to write it out on paper, I've found. Step through the operations taking place to position the image, so you can reverse them.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
>The scroll bar size does not matter, they are on the right and bottom, aren't they ?
yes, they are
>The best thing to do in a case like this is to write it out on paper, I've found. Step through the operations taking place to position the image, so you can reverse them.
you're right, i can't actually figure out how the coords go out of scale, maybe, trying on paper, i will
Cheers!
Fuel2Run
|
|
|
|
|
I am generating the columns of datagrid with auto generate column is true.I want to make only one column as hyperlink.How can i do that in vs.I am using vb.net
Thanx in anticipation
Take it easy...
|
|
|
|
|
Im trying to code a mail server using vb6, and i need some help regarding the standrards used in theses kinds of projects, i did have a look at the RFC's but that didnt help much...
Please provide some help...
SS
|
|
|
|
|
saood swar wrote:
Please provide some help...
What is today? Everyone asking "Help?", but noone is saying with what...
All the standards are in the RFC's... It's up to you how you want to implement them.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am able to use the AxMsChart in VB.net successfully, however when I try to print directly from it ... it failed!
By working around, I can only print with the screen (x,y) but it is not very good, because the users use different screen solutions. Even worse, sometimes it includes the print box message over the AxMsChart printing
*) Please do not show me in Visual Basic environment, I do not have it and when try to compile --> resulting errors!
Anyone know how to do it from VB.net?
Thanks for any help
|
|
|
|
|
A simple search on Google for "print mschart vb.net[^]" reveals LOTS of hits. Even this[^] article here on CP.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I need to have access to a parameter with more than one fuction.
Here is what i have so far and i am stuck. and i am need of help.
I have tried putting the variable at the class level ;however, i am in need to know how to implement this.
Thank you for your help ahead of time.
ERIK...
Dim IDproduct As Int32 = CInt(Request.Params("IDProduct"))
'
'.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'
'
End Sub
Protected Sub PopulateControl2()
'Fill ddlRoomsNames
'
Dim IDAttributeCategoryRooms As Int32 = CInt(Request.Params("IDAttributeCategoryRooms"))
Dim RoomNames As New ConstructionSuperCenter.Global.Global_WindowTreatment
'Get the dll
Dim ddlRoomNames As New DropDownList
'Fill
ddlRoomNames.DataSource = RoomNames.Get_Standard_Blind_Name_of_Rooms_(IDproduct, IDAttributeCategoryRooms)
ddlRoomNames.ToolTip = "Please Choose a Room"
ddlRoomNames.DataTextField = "AttributeName"
ddlRoomNames.DataValueField = "AttributeName"
ddlRoomNames.DataBind()
'
'Place Holder Rooms
'
phRooms.Controls.Add(ddlRoomNames)
End Sub
'
Protected Sub PopulateControl1()
IDproduct = (New SqlParameter("@IdProduct", IDproduct))
Dim IDAttributeCategoryColor As Int32 = CInt(Request.Params("IDAttributeCategoryColor"))
'
Dim StandardColors As New ConstructionSuperCenter.BCom.Wood_and_Alternitive_Blinds_MAIN
'Get the dll
Dim ddlStandardColor As New DropDownList
'Fill
ddlStandardColor.DataSource = StandardColors.Get_Standard_Blind_Colors_(IDproduct, IDAttributeCategoryColor)
ddlStandardColor.ToolTip = "Please Choose a Color"
ddlStandardColor.DataTextField = "AttributeName"
ddlStandardColor.DataValueField = "AttributeName"
ddlStandardColor.DataBind()
'
'Place Holder
'
phColors.Controls.Add(ddlStandardColor)
'
End Sub
End Class
|
|
|
|
|
Erik Lirttle wrote:
I need to have access to a parameter with more than one fuction.
Perhaps you should state which parameter you require access for and what portion of coding you are having problems with.
|
|
|
|
|
I need to have access to the IDProduct parameter that is being requested from the sending page. I am tring to put it at the class level so that i can have access to it class wide, that is where i am running into the trouble.
Also is the cloning method a better way to implement this?
erik..
|
|
|
|